Class Quicksort
java.lang.Object
topics.sorting.Quicksort
- All Implemented Interfaces:
ISortingAlgorithm
Quicksort sorting algorithm.
Uses divide-and-conquer with median-of-three pivot selection.
Average and best-case complexity is O(n log n), worst case is O(n^2).
- Author:
- vicegd
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Quicksort
public Quicksort()
-
-
Method Details
-
sort
public void sort(int[] elements) Description copied from interface:ISortingAlgorithmSorts elements without tracing anything- Specified by:
sortin interfaceISortingAlgorithm- Parameters:
elements- Array of numbers to be sorted
-
sort
public void sort(int[] elements, boolean trace) Description copied from interface:ISortingAlgorithmSorts elements with the possibility of tracing the operation- Specified by:
sortin interfaceISortingAlgorithm- Parameters:
elements- Array of numbers to be sortedtrace- Whether to trace the operation performed
-