AlgoScope

Coordinate Compression

PatternintermediatePatterns

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

Decision · step 2 of 9Rotate, Partition, Select: Coordinate compression
207142210039994752506i

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

Open in the player →or start at step 2

What you will see

Values sort and deduplicate; each original maps to its rank.

How rotate, partition, select works →

Cost

BestO(n log n)
AverageO(n log n)
WorstO(n log n)
SpaceO(n)

How you work with it here

play it through, step one change at a time, run it on your own input, predict what happens next.

Screen readers: Pattern lessons reuse the canonical algorithm's semantics and add a spoken "recognize this when" cue.

Reduced motion: Inherits the canonical algorithm's strategy.

Taught by the same lesson

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