Skip to content

Greedy change-making

planning ahead

Level 2 of 3

Also called Biggest coin first and The cashier's algorithm.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from greedy change-making's own run on the numbers shown.

choose one

question 1

How many comparisons does greedy make paying 8 with coins of 6, 4 and 1?

the answer, and why

the answer is D

6 fits in 8, then 6 and 4 do not fit in 2, then two 1s fit and a third does not. 3 coins taken and 3 kinds.

if you chose another

  • That is the coins greedy pays, 6, 1 and 1.
  • That is the fewest, 4 and 4.
  • That is the amount.

new numbers

question 2

How many coins does greedy pay for 13 with coins of 10, 6 and 1?

the answer, and why

the answer is B

10 fits, leaving 3. 10 and 6 do not fit in 3, so three 1s: 10, 1, 1 and 1.

if you chose another

  • That is the fewest, 6, 6 and 1, which greedy misses.
  • That pays it all in 1s.
  • No two of these coins make 13.

new numbers

question 3

Which coins and amount make greedy compare the most times? Each is written as the coins, then the amount.

the answer, and why

the answer is B

Neither 14 nor 13 fits in 12, so twelve 1s and 3 kinds, 15 in all.

if you chose another

  • Six 2s and 2 kinds, 8.
  • One 12 and 2 kinds, 3, the fewest any amount costs.
  • 10, 1 and 1, and 3 kinds, 6.

new numbers