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 13 with coins of 9, 6 and 1?

the answer, and why

the answer is B

5 coins taken and 3 kinds: each coin that fits is one comparison, and each kind is one more when it no longer fits.

if you chose another

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

new numbersthe test page's numbers

question 2

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

the answer, and why

the answer is B

Greedy takes the biggest coin that fits each time: 10, 1, 1, 1, 1, 5 coins.

if you chose another

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

new numbersthe test page's 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 D

Greedy compares 10 times on 9, 7, 1; 15, the most of the four.

if you chose another

  • On those coins it compares 8 times, fewer than 10.
  • On those coins it compares 6 times, fewer than 10.
  • On those coins it compares 7 times, fewer than 10.

new numbersthe test page's numbers