Class Util
java.lang.Object
topics.sorting.utils.Util
Helper class to trace and use common operations among sorting algorithms
- Author:
- vicegd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intfindPosMax(int[] elements, int firstElement) Finds the position of the biggest element in the arraystatic intfindPosMin(int[] elements, int firstElement) Finds the position of the smallest element in the arraystatic voidinterchange(int[] elements, int i, int j) Interchanges element i and element jstatic voidtrace(int iteration, int[] elements) Logs messages for the sorting algorithmstatic voidtraceMessage(String message, int[] elements) Logs string messages for some sorting algorithmsstatic voidtraceShellSort(int k, int pos, int[] elements) Logs messages for the Shell sorting algorithm
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
trace
public static void trace(int iteration, int[] elements) Logs messages for the sorting algorithm- Parameters:
iteration- Number of iteration in the algorithm (from 0)elements- Array with numbers
-
traceShellSort
public static void traceShellSort(int k, int pos, int[] elements) Logs messages for the Shell sorting algorithm- Parameters:
k- Value of the k parameter in the Shell algorithmpos- Value for the pos parameter in the Shell algorithmelements- Array with numbers
-
traceMessage
Logs string messages for some sorting algorithms- Parameters:
message- Message to be loggedelements- Array with numbers
-
interchange
public static void interchange(int[] elements, int i, int j) Interchanges element i and element j- Parameters:
elements- Array with numbersi- Position of one element to be interchangedj- Position of the other element
-
findPosMin
public static int findPosMin(int[] elements, int firstElement) Finds the position of the smallest element in the array- Parameters:
elements- Array with numbersfirstElement- First element from which it is going to search- Returns:
- Position of the smallest element
-
findPosMax
public static int findPosMax(int[] elements, int firstElement) Finds the position of the biggest element in the array- Parameters:
elements- Array with numbersfirstElement- First element from which it is going to search- Returns:
- Position of the biggest element
-