SortingFrom O(n²) to O(n log n)
Sorting is the most-called algorithm there is, and the best material for understanding divide and conquer, stability, and lower-bound proofs. By the end you will know why your language's built-in sort is designed the way it is, and when you can beat n log n.
Why learn Sorting
Where it shows upOrdering products by price, rating or sales, or a game leaderboard refreshed every minute. Once the data is large, O(n²) versus O(n log n) is the difference between responding and not.
→ Lesson: Merge SortA database's ORDER BY is a sorting algorithm; when the data will not fit in memory it uses an external merge sort, reading one chunk at a time.
→ Lesson: Merge SortBinary search, deduplication, merging time intervals, finding a median — all assume order. Sort first and the problem after it often becomes easy.
→ Lesson: Sorting Lower BoundAges, scores, postcodes — integers over a fixed range can be sorted without comparing at all, which is how counting sort and radix sort get past n log n.
→ Lesson: Counting Sort