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
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble | O(n²) | O(n²) | O(n²) | O(1) | Yes |
| Improved Bubble | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Direct Insertion | O(n) | O(n²) | O(n²) | O(1) | Yes |
| Direct Selection | O(n²) | O(n²) | O(n²) | O(1) | No |
| Quicksort | O(n log n) | O(n log n) | O(n²) | O(log n) | No |
| Mergesort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
Classes in This Package
Bubble— classic bubble sortImprovedBubble— bubble sort with early-exit optimisationDirectInsertion— insertion sortDirectSelection— selection sortQuicksort— in-place quicksort with partition-
— top-down merge sort (stable)
invalid reference
topics.sorting.Mergesort
-
ClassesClassDescriptionBubble Sort Algorithm - Educational Sorting Implementation.Sorting algorithm: Direct insertion methodSorting algorithm: Direct selection methodSorting algorithm: Bubble method with sentinelQuicksort sorting algorithm.