Sorting mind map
Comparison sorts, merge sort, quicksort, and heap sort.
Core idea: Sort when order turns distant relationships into neighbors or enables a one-pass invariant.
Mnemonic: Choose key → order → sweep · Cost: O(n log n) comparison bound
Merge: Stable divide & combine
Signal: Stable order, external data, or cross-half counting matters.
Move: Solve both halves, then merge with two pointers while preserving equal-key order.
Examples: Merge Sort, Count Inversions, Merge Intervals
Partition: Pivot regions
Signal: In-place average speed or only one rank is needed.
Move: Partition around a pivot; recurse both sides for sort or only the target side for selection.
Examples: Quick Sort, Quickselect, Kth Largest
Prioritize: Heap order
Signal: Repeated extremes matter more than stable full ordering.
Move: Heapify once, then repeatedly move the extreme and repair the remaining heap.
Examples: Heap Sort, Top K, Sort a Nearly Sorted Array
Distribute: Keys & buckets
Signal: Keys are bounded digits, frequencies, or a custom sortable feature.
Move: Count or bucket by key; use stable digit passes when the range itself is too large.
Examples: Counting Sort, Radix Sort, Sort Characters by Frequency