AlgoScope

Interval Scheduling

AlgorithmintermediateGreedyalso called Activity Selection

Maximum set of non-overlapping intervals; earliest finish first is optimal by an exchange argument.

Decision · step 2 of 10Intervals and Greedy Choices: Earliest finish first
012345678910abcdefghaa✓a✓bbccccccddeeeeeeffffgggghhh

a is 1-4. It starts at 1, which is after the last kept interval ended (0), so keep it. The next one must start at 4 or later.

Open in the player →or start at step 2

What you will see

Same as activity selection with an exchange-argument overlay: any other choice can be swapped for ours.

How intervals and greedy choices works →

Cost

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

How you work with it here

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

Screen readers: Candidates announce their key and state (candidate, chosen, rejected); each step announces the local choice and its consequence.

Reduced motion: Chosen and rejected states crossfade; no travelling emphasis.

A variant of

Taught by the same lesson

Intervals and Greedy Choices covers these too, in the same run.