Interval Partitioning
Sort by start; assign each interval to the first room that is free, else open a new room.
Decision · step 2 of 8Intervals and Greedy Choices: Assigning rooms
a is 0-3. No rooms yet, so it opens room 1.
What you will see
Rooms as rows; each interval drops into the first row where it fits.
Cost
| Best | O(n log n) |
|---|---|
| Average | O(n log n) |
| Worst | O(n log n) |
| Space | O(n) |
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.
Before this
Taught by the same lesson
Intervals and Greedy Choices covers these too, in the same run.