Package com.collection.arraylist
Class QuickSort
java.lang.Object
com.collection.arraylist.QuickSort
This class provides a static method for performing a quicksort algorithm on a CustomArrayList
containing elements that implement the Comparable interface.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Comparable<T>>
voidsort(CustomArrayList<T> arr) Sorts the elements in the given CustomArrayList using the quicksort algorithm.static <T> voidsort(CustomArrayList<T> arrayList, Comparator<T> comparator) Method to sort the elements in the given CustomArrayList using the Quick Sort algorithm.
-
Constructor Details
-
QuickSort
public QuickSort()
-
-
Method Details
-
sort
Method to sort the elements in the given CustomArrayList using the Quick Sort algorithm. It starts the methodquickSort(CustomArrayList<T> arrayList, int low, int high, Comparator<? super T> comparator)and launches the quick sort algorithm.- Type Parameters:
T- the type of elements that this QuickSort class can sort- Parameters:
arrayList- the CustomArrayList to be sortedcomparator- the comparator to determine the order of the elements
-
sort
Sorts the elements in the given CustomArrayList using the quicksort algorithm. It starts the methodquicksort(CustomArrayList<T> arr, int low, int high)and launches the quick sort algorithm.- Type Parameters:
T- the type of elements in the CustomArrayList, must implement Comparable interface- Parameters:
arr- the CustomArrayList to be sorted
-