Greedy Choice and the Exchange Argument · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Grabbing the best seat first, with proof

Computing · Algorithms & Data Structures · ages 19-21
Name ______________________   Date ____________
  1. What does a greedy method never do?

    • Take the locally best option
    • Reconsider an old pick
    • Run fast
  2. Which rule books the most activities?

    • Take the one that finishes earliest
    • Take the one that starts latest
    • Take the longest one first
  3. A greedy rule is safe to use without any proof.

    Circle one:   True   False

  4. Coins 1, 3, 4. Largest-first for 6 uses how many coins? Type the count.

    Answer: ______________

  5. Why does swapping in the earliest-finishing pick never hurt?

    • It ends no later, so room only grows
    • It rewrites the past
    • It adds extra rooms
  6. What must hold before a greedy rule can be correct?

    • Inputs arrive sorted by color
    • The first grab sits in some best answer and the rest keeps its shape
    • The programmer feels lucky
  7. Since 3 plus 3 beats 4 plus 1 plus 1, largest-first is wrong for that coin set.

    Circle one:   True   False

  8. A student shows greedy winning on three room sets and claims proof. What is the flaw?

    • Three sets are too few to read
    • Rooms dislike all examples
    • Examples never replace the swap argument
LightMySky · lightmysky.comW1-mt_9Fj28VDAV--s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Grabbing the best seat first, with proof W1-mt_9Fj28VDAV--s1

  1. Reconsider an old pick · Greedy takes and never looks back.
  2. Take the one that finishes earliest · Earliest finish leaves the most room behind.
  3. False · Only a proof licenses the rule.
  4. 3 · It takes 4, 1, 1, which is three coins.
  5. It ends no later, so room only grows · An earlier end keeps every later fit possible.
  6. The first grab sits in some best answer and the rest keeps its shape · A safe first pick plus same-shaped rest licenses greedy.
  7. True · One failure ends the rule for that set.
  8. Examples never replace the swap argument · Proof must cover every set, not sample a few.
Worksheet · LightMySky