Coordinate Compression
Sort the distinct values and replace each value by its rank. Order survives, the range shrinks.
Rotate, Partition, Select: Coordinate compression
100 is the 3rd smallest distinct value, so it becomes 2.
Cost
- Best
- O(n log n)
- Average
- O(n log n)
- Worst
- O(n log n)
- Space
- O(n)
Before this
Taught by the same lesson
Rotate, Partition, Select covers these too, in the same run.