Sorting & Selection
Sorting organizes collections into total order; selection locates the k-th smallest element without fully sorting. Merge Sort achieves deterministic O(N log N) worst-case comparison time with stability; Quicksort partitions in-place with O(N log N) expected time; Radix Sort sorts keys digit-by-digit in O(W·N) non-comparison time.
Key Invariants & Rules
- Top-Down Merge Sort divides recursively at midpoint floor((lo + hi)/2) and merges sorted halves stably.
- 3-way Quicksort partitions elements into strictly smaller, equal, and strictly greater bands.
- Radix Sort preserves duplicate stability across bitwise passes from LSB to MSB.
- Quickselect partitions only the sub-array containing the target rank k, achieving O(N) average time.
- Tied comparisons never invert original relative order in stable algorithms.
Must-Know Algorithms
Guaranteed optimal comparison bound, highly predictable, and fundamentally stable.
Dutch National Flag partition handles heavy duplicate keys gracefully in-place.
Non-comparison sort grouping integers by bit patterns across 32 binary passes.
Learning Path (10 Lessons)
Self-Check & Concept Review
1. Why does Top-Down Merge Sort require an auxiliary array of size N?
2. What is the advantage of 3-way partitioning (lt, i, gt) over standard 2-way partitioning in Quicksort?
3. How does Quickselect achieve O(N) average time compared to sorting the whole array?
4. Why must Radix Sort use a stable inner sorting algorithm on each digit/bit pass?
5. In linked list merge sort, why is extra auxiliary array space not required?