AlgoScope

Coordinate Compression

Sort the distinct values and replace each value by its rank. Order survives, the range shrinks.

Problem-solving patterns, pattern, intermediate
100 becomes rank 2.207142210039994752506i
100 becomes rank 2.207142210039994752506i

Rotate, Partition, Select: Coordinate compression

Decision, step 2 of 9

100 is the 3rd smallest distinct value, so it becomes 2.

How rotate, partition, select works

Cost

Best
O(n log n)
Average
O(n log n)
Worst
O(n log n)
Space
O(n)

Taught by the same lesson

Rotate, Partition, Select covers these too, in the same run.