An empty table of 7 slots puts in 3, 10, 17, 24 and 31, all with home 3. How many probes do the five puts make in all?
the answer, and why
the answer is A
3 takes slot 3, 1 probe. Each of the others has its own step, 1, 3, 5 and 2, and finds slot 3 taken, then a free slot. 1 + 2 + 2 + 2 + 2 is 9.
step 17 of 21
31 leaves 3 when divided by 7, so its home is slot 3.
slots looked at: 0
step 18 of 21
31 leaves 1 when divided by 5, so its step is 2: each move goes 2 slots on, round to the start.
slots looked at: 0
step 19 of 21
Slot 3 holds 3, not 31.
slots looked at: 1
step 20 of 21
Slot 5 is free, so put 31 there.
slots looked at: 2
Operation 5 puts 31 in, step 2. Slot 3 holds 3, and slot 5 is free. 2 probes, though four numbers came first.
if you chose another
BThat walks one slot on each time, as linear probing does, 1 + 2 + 3 + 4 + 5.
CThat counts 1 probe a put, but each after 3 finds slot 3 taken.
DThat counts 2 probes for 3 too, but its home is free.
2question 2
An empty table of 7 slots puts in 17 and 10, then 24. Which slot does 24 go in?
the answer, and why
the answer is A
17 takes slot 3. 10, home 3 and step 1, takes slot 4. 24 has home 3 and step 5. Slot 3 holds 17, and 3 + 5 is 8, which leaves 1 after dividing by 7. Slot 1 is free.
if you chose another
BSlot 4 already holds 10. 24's step is 5, so from slot 3 it moves to slot 1.
CSlot 3 is 24's home, but 17 already holds it.
DThat walks one slot on each time, 3, 4, 5, as linear probing does. 24's step is 5.
3question 3
Say a table had 6 slots, and a number with home 0 had a step of 2. Which slots could its walk ever look at?
the answer, and why
the answer is D
0, then 2, then 4, then 6, which leaves 0 after dividing by 6, so back to 0. 2 shares the factor 2 with 6, so slots 1, 3 and 5 are never looked at.
BThey go different ways at the first move unless their steps agree. 10 and 24 share home 3, with steps 1 and 5.
CA step of 7 lands back on the home every time, as 7 leaves 0 after dividing by 7.
DFrom the 8th on, both look at all 7 slots.
pen and paper
5question 5about 6 minutes
In a table of 7 slots, every slot holds a number except slot 5. A put of a new number has step 3, and its home is any of the 7 slots, each as likely.
For each home, 0 to 6, how many probes does the put make?
What is the average?
Check it against , the formula of section 4, with the 7 slots.
a hint
From each home, add 3 each time, keeping the remainder after dividing by 7, until slot 5.
a worked answer
Home 5 makes 1 probe, home 2 makes 2, home 6 makes 3, home 3 makes 4, home 0 makes 5, home 4 makes 6 and home 1 makes 7. They add to 28, and 28 over 7 is 4. The formula with 7 slots gives 8 over 2, also 4.
home
its walk
probes
5
5
1
2
2, 5
2
6
6, 2, 5
3
3
3, 6, 2, 5
4
0
0, 3, 6, 2, 5
5
4
4, 0, 3, 6, 2, 5
6
1
all 7
7
Each home a different distance from slot 5 along a step of 3, 1 to 7.
Here let count slots, not numbers put in. A table of slots has one free slot. A put of a new number has a step that is the same whatever its home. Its walk meets every slot once before any twice, as each step 1 to 5 does in 7 slots. How many probes does it make, on average over its home?5 of 5 shown
1the move: walk to the free slot
the line:
home
its walk
probes
5
5
1
2
2, 5
2
6
6, 2, 5
3
3
3, 6, 2, 5
4
0
0, 3, 6, 2, 5
5
4
4, 0, 3, 6, 2, 5
6
1
1, 4, 0, 3, 6, 2, 5
7
7 slots, only slot 5 free, step 3. Every walk is the end of 1, 4, 0, 3, 6, 2, 5, so each home gives a different number of probes, 1 to 7.
why it is allowed: Its walk meets every slot once before any twice, as the question says. Walk back from the free slot by the step: that meets each home once, so each home is a different number of probes away, 1 up to . Its home is any of the slots, each as likely. This prices a put when one slot is left.
2the move: average over the homes
the line:
why it is allowed: is the probes averaged over the homes. By line 1, the homes give 1 up to , one each. For 7, 28 over 7.
guess it, then
3the move: use the page on adding up
the line:
where does this come from?
question 1 of the page adding up Fit two staircases of squares together. What shape do they make?
1the move: draw the sum as a staircase
the line:
why it is allowed: Let be the sum of the whole numbers from 1 to . Draw it as a staircase, a column for each number: 1 square, then 2, and so on up to . For 5, columns of 1, 2, 3, 4 and 5 hold 15 squares.
2the move: take two staircases
the line:
why it is allowed: Two staircases hold twice the squares. Doubling both sides of line 1 keeps it true.
3the move: fit them into a rectangle
the line:
Blue stands, yellow hangs. Two staircases of 1 to 5 squares fill a rectangle 5 wide and 6 tall, 30 squares. So 1 + 2 + 3 + 4 + 5 is 5 times 6, halved, which is 15.
why it is allowed: Stand one staircase with its tallest column on the left. Hang the other upside down from the top, its tallest column on the right, as in the picture. The first column holds standing and 1 hanging. Each column to the right, the standing one loses a square and the hanging one gains one. So every column holds , and the columns fill a rectangle wide and tall.
4the move: halve both sides
the line:
why it is allowed: Halving both sides of line 3 keeps it true and leaves one . For 5, half of 30 is 15.
why it is allowed: The box under this line shows that 1 up to a last number adds to that number times one more, halved. Here the last number is . For 7, 7 times 8, halved, is 28.
guess it, then
4the move: put the two divisions under one line
the line:
why it is allowed: Halved, then over , is over twice . For 7, 7 times 8 over 14 is 4.
guess it, then
5the move: tidy
the line:
why it is allowed: The on top and below cancel. For 7 slots, 8 over 2 is 4. Section 3's 7th put averages about 3.99 instead, as there the step changes with the home.
guess it, then
try it with a small : at , line 2 gives , which you can work out by hand
An empty table of 7 slots puts in 17, 10 and 24, takes 24 out, then puts in 59.
Where does each of 17, 10 and 24 go?
What does taking 24 out leave?
Which slot does 59 go in, and after how many probes?
a hint
17, 10, 24 and 59 all have home 3. A put notes the first marker it passes, but walks on to a free slot first.
a worked answer
17 takes slot 3, 10 slot 4 (step 1) and 24 slot 1 (step 5). Taking 24 out leaves a marker in slot 1. 59 has step 5 too. It looks at slot 3 (17), slot 1 (the marker, noted) and slot 6, free: 3 probes. 59 is nowhere further along, so it goes in slot 1, where the marker was.
step 18 of 23
59 leaves 3 when divided by 7, so its home is slot 3.
slots looked at: 0
step 19 of 23
59 leaves 4 when divided by 5, so its step is 5: each move goes 5 slots on, round to the start.
slots looked at: 0
step 20 of 23
Slot 3 holds 17, not 59.
slots looked at: 1
step 21 of 23
Slot 1 holds a marker left by a number taken out. Note it: 59 can go here if it is nowhere further along.
slots looked at: 2
step 22 of 23
59 is nowhere further along, so put it in slot 1, where the first marker was.
slots looked at: 3
Operation 5 puts 59 in, step 5. It notes the marker in slot 1, walks on to the free slot 6, then goes in slot 1. 3 probes.