Log inStart free
LESSON 3.10 · 6 STAGES · 2 CONTROLS · 3 CHECKSPRO · PREVIEW

Greedy algorithms

Watch three greedy rules book one room, and see which one always wins.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 2 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 3.10 · GREEDY BAY8 MEETINGS · HOURS 8–20 · MON
01
Stage 1 of 6 · Meeting requests
On Monday, 8 meetings ask for one room. The goal is the most meetings with no overlap.
Explain it simply

Each bar is a meeting, from its start hour to its end hour. Two bars that share time can't both use the room. You want to fit as many meetings as you can. Trying every possible set works, but the number of sets doubles with each new meeting.

8 meetings, A to H, sit on a time axis from hour 8 to hour 20. A runs from 18 to 20. B runs from 11 to 13. C runs from 9 to 12. D runs from 8 to 16. E runs from 17 to 19. F runs from 13 to 17. G runs from 14 to 15. H runs from 15 to 18.

meeting requestrule keytaken meeting, scheduleoverlap, falls behinddropped meeting
requesttime (hour)891011121314151617181920roomABCDEFGHrequesttime (hour)891011121314151617181920roomABCDEFGH
Toy: 8 meetings · one room · hours 8 to 20 · 3 rules × 3 days
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
max⁡ ∣S∣ such that fi≤sj or fj≤si for i≠j∈S\max\ |\sy{S}{out}{S}| \ \text{such that}\ \sy{f}{data}{f_i} \le \sy{s}{data}{s_j}\ \text{or}\ f_j \le s_i\ \text{for}\ i \ne j \in S
n=8,28=256 subsets;A: s=18, f=20n = 8,\quad 2^{8} = 256\ \text{subsets};\quad A:\ s = 18,\ f = 20

Pick the largest set S in which no two meetings share time.

Common mix-ups

MYTHAny sensible greedy rule finds the best schedule.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With starts first on Monday, how many meetings fit in the room?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 2 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.