ASharing a home makes more probes, not more moves.
BOnly a put that doubles the slots moves numbers; the 4th moves none.
CThe moves are , with half the slots at the end, at most .
pen and paper
5question 5about 6 minutes
A table that grows starts with 2 empty slots and puts in 1 to 9, one at a time.
Which puts double the slots, and how many numbers does each move?
How many moves in all?
Check it against , from section 4 of the learn page, with half the slots at the end.
a hint
Before each put, ask whether it would make the table more than half full.
a worked answer
The 2nd, 3rd, 5th and 9th puts double the slots, moving 1, 2, 4 and 8. They add to 15. After 9 numbers there are 32 slots, so is 16, and 16 less 1 is 15.
put
slots before
moves
2
2
1
3
4
2
5
8
4
9
16
8
The four puts that double, and what each moves. 15 in all.
Why do different numbers make moves, whichever they are, and under ?14 of 14 shown
1the move: the slots double before half is passed
the line:
why it is allowed: The table starts with 2 slots and is never more than half full. The 9th new number finds 8 numbers in 16 slots, half; with it, 9 is more than half, so the slots double. In general, with the th new number are in, so it doubles them when is more than half of them. Only the count decides it, never which numbers.
2the move: price a doubling
the line:
step 30 of 39
Slot 1 is empty, so put 1 there.
slots looked at: 2
step 32 of 39
Slot 2 is empty, so put 2 there.
slots looked at: 3
step 34 of 39
Slot 3 is empty, so put 3 there.
slots looked at: 4
step 36 of 39
Slot 4 is empty, so put 4 there.
slots looked at: 5
Operation 5 puts 5 in. 5 numbers in 8 slots is more than half, so the slots double to 16, and all 4 numbers move.
why it is allowed: By line 1, before a new number that doubles them, the th, one fewer than fill at most half the slots, and fill more than half. So half the slots is one fewer than , and all of them move. In 16 slots, half is 8: the numbers in are at most 8, and with one more they are over 8, so they are exactly 8. The slots run 2, 4, 8, so it moves 1, then 2, then 4. Before the 5th number, 4 numbers fill 8 slots to half, and all 4 move.
guess it, then
3the move: the last half
the line:
why it is allowed: For 9, the 9th doubled 16 slots to 32, so is 16: 8 is below 9, and 16 is at or above 9. In general, half the slots runs 1, 2, 4, and on, so is a power of 2. The table is at most half full, so is at least . By line 2, the last doubling came at some new number up to the th, when the numbers in, fewer than , filled half the old slots. The doubling made twice slots from , so the numbers in filled half of , and half of is below .
guess it, then
4the move: add the moves
the line:
why it is allowed: is the moves of different numbers. By lines 2 and 3, the doublings move 1, 2, 4, and on, up to half of , the last one. For 9, 1 + 2 + 4 + 8, and is 16.
guess it, then
5the move: add the doublings
the line:
where does this come from?
question 1 of the page doubling and halving sumsAdd . What is the total?
1the move: name the sum
the line:
why it is allowed: Let be the doubling sum up to . For as 3, it is 1 + 2 + 4 + 8.
2the move: double both sides
the line:
why it is allowed: Each term doubled is the next one along, and becomes . Doubling both sides keeps them equal. The plan: the two sums share all but their ends.
3the move: take line 1 away
the line:
why it is allowed: Take from both sides of line 2. On the right, write out as line 1 does.
4the move: tidy the left side
the line:
why it is allowed: Two lots of less one lot is one lot.
5the move: cancel what both brackets share
the line:
when n is 3
1
2
4
8
16
first bracket
2
4
8
16
second bracket
1
2
4
8
left over
take away 1
16
Line 4 when is 3. The 2, 4 and 8 cancel, leaving 16 less 1, which is 15.
why it is allowed: Every term from 2 to is in both brackets and cancels, leaving less 1.
6the move: the terms before the last
the line:
why it is allowed: The sum of line 5 stopping one term sooner: line 5 with for . For 3, it is 1 + 2 + 4. At as 0 no terms are left, adding to 0, and 2 to the power 0, less 1, is 0 too.
7the move: tidy the power
the line:
why it is allowed: One more than is . For 3, 1 + 2 + 4 is 7, one less than 8.
8the move: read it
the line:
why it is allowed: By lines 6 and 7, the terms before the last add to one less than it: the last outweighs them all. By line 5 the sum is under , twice the last.
why it is allowed: The box under this line shows a doubling sum from 1 is one less than the next doubling. In the box, is how many times 1 doubles to reach the last number added. It is not the numbers: for 9 numbers it is 3, as 1 doubled 3 times is 8, half of . After half of comes . For 9, 15 is 16 less 1.
guess it, then
6the move: half the slots is under twice the numbers
the line:
why it is allowed: By line 3, half of is below . Doubling both, is below . For 9, 8 is below 9, so 16 is below 18.
guess it, then
7the move: a ceiling
the line:
why it is allowed: By lines 5 and 6, is less 1, and is below , so is below . For 9, 15 is at most 17.
guess it, then
8the move: read it as a bound
the line:
why it is allowed: By line 7, with the fixed multiple 2.
guess it, then
9the move: half the slots holds every number
the line:
why it is allowed: By line 3. For 9, 16 is at least 9.
guess it, then
10the move: a floor
the line:
why it is allowed: By lines 5 and 9, less 1 is at least less 1. For 9, 15 is at least 8.
guess it, then
11the move: a simpler floor
the line:
why it is allowed: From 2 on, less 1 is at least half of , as half of is at least 1. For 2, 1 is at least 1.
guess it, then
12the move: read it as a bound
the line:
why it is allowed: By line 11, with the fixed multiple one half, from 2 numbers on.
guess it, then
13the move: ceiling and floor together
the line:
why it is allowed: Lines 8 and 12 bound by the same growth, .
guess it, then
14the move: share it out
the line:
why it is allowed: Line 7 divided by shares the moves over the numbers, the amortised cost. For 9, 15 over 9 is about 1.67, at most 2 less 1 over 9, about 1.89.
guess it, then
try it with a small : at , line 4 gives , which you can work out by hand
The 2nd, 3rd, 5th and 9th puts, moving 1, 2, 4 and 8.
15 moves.
The formula giving 15 for of 16.
6question 6about 8 minutes
A table that grows starts with 2 empty slots and puts in 1, 17 and 33, every one with home 1 in every room.
Count the probes of each put.
How many probes in all?
a hint
Each walk passes every number before it. Count the moves' walks and the walk again after each doubling.
a worked answer
1 makes 1 probe. 17 makes 2, finding slot 0 empty. The slots double to 4: 1 moves in 1 probe, and 17 looks again, 2 probes. 33 makes 3 in 4 slots, slot 3 empty. They double to 8: 1 moves in 1, 17 in 2, and 33 looks again, 3. So 1, 5 and 9 probes, 15 in all.