Every sorting algorithm covered so far — insertion sort, mergesort, heapsort, quicksort — decides the relative order of elements purely by comparing them, and it turns out no such algorithm can beat in the worst case, a fact this note proves first. But that lower bound has an escape hatch: if the keys being sorted have extra exploitable structure (bounded integer range, fixed-width digits, a known distribution), an algorithm that never compares two elements directly can sort in . This note proves the comparison lower bound, then builds the three classical linear-time sorts — counting sort, radix sort, and bucket sort — each exploiting a different kind of structure.
In this lesson
- Learning objectives
- The comparison-sort lower bound
- Counting sort
- Radix sort
- Bucket sort
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or explore the curriculum.