C5 is no number of 4s, yet greedy pays it as 4 and 1, the fewest.
DWith 1 and one other coin greedy never loses, as question 3 in section 4 of the learn page shows.
pen and paper
5question 5about 8 minutes
Coins of 8, 5 and 1. Find the smallest amount where greedy pays more coins than it needs.
Try amounts from 1 up, greedy against the fewest. Where does greedy first lose?
At that amount, which coins does greedy pay, with how many comparisons?
Fill in every way at that amount, by how many 8s and 5s it takes.
a hint
A way is fixed by its 8s and 5s; 1s pay the rest.
a worked answer
Below 8 only 5 and 1 fit, and with 1 and one other greedy never loses (learn page, section 4, question 3); 8 and 9 take one 8. At 10, 8 fits, leaving 2, and 8 and 5 do not fit in 2. Two 1s fit and a third does not: 8, 1 and 1, 3 coins, with 6 comparisons, but 5 and 5 is 2. The ways at 10 are drawn below: no 8s and no 5s take 10 coins, one 5 takes 6, two 5s take 2, and one 8 takes 3. One 8 with any 5 pays too much.
ways
0 of 5
1 of 5
2 of 5
0 of 8
10
6
2
1 of 8
3
-
-
Every way to pay 10, counted in coins. A dash pays too much.
Section 4's questions 1 and 2 count the most and the fewest.
a worked answer
At most 1,000 + 3, which is 1,003, when every coin is a 1. At least 3, on 1 and a coin of 1,000. Coins of 1, 1,001 and 1,002 reach the most, as neither big coin fits; coins of 1 and 1,000 reach the fewest.
Question 1: at most how many comparisons, , can greedy make paying , from 1 up?11 of 11 shown
1the move: one for each coin taken
the line:
why it is allowed: A coin is taken only after it is held against what is left and fits. On the till, 6 coins, 6 that fit.
2the move: one for each kind
the line:
why it is allowed: Greedy holds a coin again and again until it does not fit, once, then goes on to the next. On the till, 3 kinds, 3 that do not fit.
guess it, then
3the move: coins taken
the line:
why it is allowed: The coins taken add up to , and each is worth 1 or more. So there are at most of them.
guess it, then
4the move: kinds
the line:
why it is allowed: The coins come in 2 or 3 kinds, one of them 1.
guess it, then
5the move: the dearest coins reach both
the line:
hold
against what is left
fits
6
4
no
5
4
no
1
4, 3, 2, 1
yes, 4 times
1
0
no
Paying 4 with 6, 5 and 1. 4 coins taken and 3 kinds: 7 comparisons.
why it is allowed: Neither big coin fits in , so greedy pays it all in 1s, coins, with 3 kinds. Lines 3 and 4 are both reached.
guess it, then
6the move: add them
the line:
why it is allowed: By lines 1 to 5, the most coins taken and the most kinds, which the dearest coins make. For 4, 4 + 3, which is 7.
guess it, then
7the move: a ceiling
the line:
why it is allowed: From 1 up, 3 is at most , so is at most . For 4, 7 is at most 16.
guess it, then
8the move: read the bound
the line:
why it is allowed: By line 7, with the fixed multiple 4. reads is in, and means at most a fixed multiple of , from some on.
guess it, then
9the move: a floor
the line:
why it is allowed: is more than . For 4, 7 is at least 4.
guess it, then
10the move: read the bound
the line:
why it is allowed: By line 9, with the fixed multiple 1. means at least a fixed multiple of , above 0, from some on.
guess it, then
11the move: both together
the line:
why it is allowed: Lines 8 and 10 bound by the same growth. means both.
guess it, then
try it with a small : at , line 6 gives , which you can work out by hand