Package topics.sorting


package topics.sorting
Sorting algorithms — from simple quadratic to optimal linearithmic.

Sorting is one of the most studied problems in computer science. This package provides implementations of the major comparison-based sorting algorithms, covering the spectrum from O(n²) educational sorts to O(n log n) efficient sorts, plus a non-comparison-based radix sort.

Algorithm Comparison

Complexity and property summary
AlgorithmBestAverageWorstSpaceStable
BubbleO(n²)O(n²)O(n²)O(1)Yes
Improved BubbleO(n)O(n²)O(n²)O(1)Yes
Direct InsertionO(n)O(n²)O(n²)O(1)Yes
Direct SelectionO(n²)O(n²)O(n²)O(1)No
QuicksortO(n log n)O(n log n)O(n²)O(log n)No
MergesortO(n log n)O(n log n)O(n log n)O(n)Yes

Classes in This Package