AlgoScope

Adaptive Algorithms

AnalysisintermediateAlgorithm Properties

Timsort on already sorted input finds a single run and finishes in one pass.

Decision · step 2 of 4More Sorts: Timsort on sorted input
run 0-710416293134205216307

From index 0 the values keep rising for 8 slots: a natural run of length 8. That is at least 4, so it is taken as it is.

Open in the player →or start at step 2

What you will see

Insertion sort on nearly sorted input finishes in a fraction of the steps.

How more sorts works →

Cost

SpaceO(1)

How you work with it here

explore, compare two runs, run it on your own input.

Screen readers: Growth curves are described in words and as a table of operation counts for sample input sizes; each concept has a one-sentence spoken definition.

Reduced motion: Curves and counters update without animation.

Taught by the same lesson

More Sorts covers these too, in the same run.