AThat needs buckets that grow with the numbers. Here the next put at 1,000 numbers meets about 200.
BDivide line 14 of section 4's spread-in-turn question by . The looks per number are at least over 10, 9.1 at 100 and 99.1 at 1,000. That passes any fixed number, so no fixed multiple of holds them.
CFor different numbers, the looks are the pairs sharing a bucket, which no order changes.
4question 4
An empty table puts in 12, 7 and 32, takes 7 out, then puts in 22. How many looks do the five operations make?
the answer, and why
the answer is C
12 finds bucket 2 empty, 0. 7 meets 12, 1. 32 meets 12 and 7, 2. Taking 7 out meets 12, then finds 7, 2. 22 meets 12 and 32, 2. That is 7.
step 11 of 19
7 leaves 2 when divided by 5, so if it is here at all, it is in bucket 2.
compared: 0
step 12 of 19
12 is not 7.
compared: 1
step 13 of 19
Here is 7, in bucket 2.
compared: 2
step 14 of 19
Take 7 out of bucket 2.
compared: 2
Operation 4 takes 7 out. It meets 12, then finds 7, 2 looks, and 7 leaves bucket 2. Yellow is being compared, and 7 is filled in when found.
if you chose another
AThat counts the take as a walk of the whole bucket, but it stops at 7.
BThat leaves out the take's 2 looks.
DThat counts the take as 1 look, but it meets 12 before it finds 7.
pen and paper
5question 5about 8 minutes
Put 1 to 12 into an empty table of 5 buckets, in that order.
Which bucket does each number go in?
How many looks does each put make?
Check your total against , line 5 of the spread-in-turn question.
a hint
Numbers 1 to 5 fill one round of buckets, 6 to 10 a second, and 11 and 12 start a third.
a worked answer
Puts 1 to 5 find empty buckets, 0 looks. Puts 6 to 10 each meet one number, 5 looks. 11 and 12 each meet two, 4 looks. That is 9 in all. The sum, for 12: five 0s, five 1s and two 2s, also 9.
puts
bucket
looks each
1, 2, 3, 4, 5
1, 2, 3, 4, 0
0
6, 7, 8, 9, 10
1, 2, 3, 4, 0
1
11, 12
1, 2
2
in all
9
Three rounds over the buckets. A put meets one number from each earlier round.
Why do 1 to , spread over the buckets in turn, cost the fewest looks, and how many?16 of 16 shown
1the move: a look is a pair
the line:
7, 12, 3 and 17 put in. Bucket 2 holds 7, 12 and 17, 3 pairs: 7 and 12, 7 and 17, 12 and 17. 12 makes 1 look and 17 makes 2. 3 shares its bucket with nothing.
why it is allowed: By line 1 of the one-bucket question, a put compares its number with every number already in its bucket. So two numbers in one bucket meet once, when the later goes in. Two in different buckets never meet.
2the move: even out the sizes
the line:
17 swapped for 15, which leaves 0. Bucket 2 drops to 7 and 12, 1 pair, and 15 shares bucket 0 with nothing.
buckets 2 and 0 hold
pairs in each
looks
3 and 0
3 and 0
3
2 and 1
1 and 0
1
Line 1's bucket 2 against bucket 2 after the swap. 17 leaves 2 pairs and joins none, so the swap saves 2 looks.
why it is allowed: Swap 17 for 15. 17 met 7 and 12, so 2 pairs go; 15 lands in empty bucket 0, so none come: 2 looks saved, by line 1. In general, one fewer than pairs go and at most come.
guess it, then
3the move: the cheapest are even
the line:
7 numbers with sizes 3, 2, 1, 1 and 0, largest first. 3 pairs in bucket 2 and 1 in bucket 3, 4 looks.
1 to 7, sizes 2, 2, 1, 1 and 1, largest first. 1 pair in bucket 1 and 1 in bucket 2, 2 looks, the fewest for 7 numbers.
why it is allowed: If two sizes are 2 or more apart, line 2's swap saves a look, so that spread is not the cheapest. With no two sizes 2 or more apart, every size is or one more, where is over 5 rounded down. 5 buckets of hold numbers, and the left over make that many buckets one more. For 7, is 1, so 2 buckets hold 2 and 3 hold 1: 2 + 2 + 1 + 1 + 1 is 7. So all such spreads cost the same, by line 1, as 1 to 7 do.
guess it, then
4the move: price the kth put
the line:
1 to 12 put in, in turn. 12 lands in bucket 2 and meets 2 and 7, 2 looks.
why it is allowed: The numbers before it fill whole rounds of 5, one in each bucket, then part of a round. The part round fills only the buckets before its own in the turn 1, 2, 3, 4, 0. So its bucket holds one from each whole round. For 12, 11 over 5 is 2.2, rounded down 2: the 2 and the 7.
guess it, then
5the move: add the puts
the line:
why it is allowed: is the looks of 1 to put in. By line 4, puts 1 to make up to . For 10, five 0s and five 1s, 5.
guess it, then
6the move: count by rounds
the line:
puts
round
looks each
looks
1 to 5
first
0
0
6 to 10
second
1
5
11 and 12
part of a third
2
4
in all
9
1 to 12 by rounds. Two whole rounds, so is 2, and 2 puts left over.
why it is allowed: Let be the whole rounds of 5 puts, over 5 rounded down. In line 5, the rounds add 0, then 1, and on up to , five times each. The puts left over add each. For 12, is 2: 5 times 1, plus 2 times 2, is 9.
guess it, then
7the 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 , and the 0 adds nothing: times , halved, five times. For 12, 5 times 1, plus 4, is 9.
guess it, then
8the move: drop the rounding
the line:
why it is allowed: Line 7's is awkward beside , so for how fast grows, go back to line 5. Rounding down never makes a number bigger. Fifths add their tops: 0 fifths, 1 fifth and 2 fifths make 3 fifths. For 10, 5 is at most 45 over 5, which is 9.
guess it, then
9the 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 same box, with last number : line 8's top is , and a fifth of that is . For 10, 9.
guess it, then
10the move: a ceiling
the line:
why it is allowed: In line 9, is less than . For 10, 9 is at most 10.
guess it, then
11the move: read it as a bound
the line:
why it is allowed: By line 10, with the fixed multiple a tenth.
guess it, then
12the move: rounding down loses at most 4 fifths
the line:
top
top over 5
rounded down
lost
5
1
1
0
6
1.2
1
0.2
7
1.4
1
0.4
8
1.6
1
0.6
9
1.8
1
0.8
Rounding a fifth down loses 0, 1, 2, 3 or 4 fifths, never more.
why it is allowed: Each of line 5's pieces is its fifth, less what rounding down loses, at most 4 fifths. So pieces lose at most times 4 fifths. For 10, 5 is at least 9 less 8.
guess it, then
13the move: the same sum
the line:
why it is allowed: Line 12's sum is line 8's, which line 9 found to be . For 10, 9 less 8, which is 1.
guess it, then
14the move: tidy
the line:
why it is allowed: In line 13, 4 fifths of is 8 tenths of . Take out of both tenths: times , less times 8, is times . For 20, 20 times 11 over 10 is 22, and is 30.
guess it, then
15the move: read it as a bound
the line:
the ceiling, a tenth of
, spread in turn
the floor, a twentieth of
From 18 numbers on, stays between a twentieth and a tenth of . At 40, 140 lies between 80 and 160.
why it is allowed: By line 14. From 18 numbers on, 9 is at most half of , so is at least half of . Then is at least a twentieth of , the fixed multiple. At 20, 30 is at least 20.
guess it, then
16the move: ceiling and floor together
the line:
why it is allowed: Lines 11 and 15 bound by the same growth, .
guess it, then
try it with a small : at , line 5 gives , which you can work out by hand
Put 3 numbers into an empty table of 5 buckets, each landing in a bucket picked at random. Each of the 125 ways, 5 times 5 times 5, is as likely.
How many looks does the second put make, on average?
And the third?
Add them, and check against at 3.
a hint
A put makes a look for each number already in its bucket, and its bucket is any of the 5.
a worked answer
The second put meets the first only when it lands in the first's bucket, 1 of the 5: 1 over 5 on average. The third's 5 buckets hold the 2 numbers already in, 2 over 5. Together 3 over 5, 0.6. The formula gives 2 times 3 over 10, also 0.6.
put
numbers already in
looks on average
1
0
0
2
1
1 over 5
3
2
2 over 5
in all
3 over 5
Each put averages the numbers already in over the 5 buckets, the load.
Why do numbers landing at random cost looks on average?10 of 10 shown
1the move: average one put over its bucket
the line:
the third number lands in
numbers there
looks
bucket 0
none
0
bucket 1
none
0
bucket 2
27
1
bucket 3
13
1
bucket 4
none
0
on average
2 over 5
13 and 27 are in. The third number's 5 buckets make 2 looks in all, 2 over 5 on average, numbers over buckets.
why it is allowed: Its bucket is any of the 5, each as likely, so average its looks over the 5. By line 1 of the one-bucket question, each bucket's looks are the numbers there. Wherever the numbers already in went, the 5 buckets hold in all. Had 13 and 28 shared bucket 3, it would give 2 and the rest 0: still 2 over 5.
2the move: add the puts' averages
the line:
why it is allowed: By line 1, whatever the earlier numbers did, puts 1 to average 0 up to over 5. Let be these averages added. For 3, 3 over 5.
guess it, then
3the move: an average adds its pieces
the line:
buckets of 3 numbers
put 2's looks
put 3's looks
looks in all
0, 0, 0
1
2
3
0, 0, 1
1
0
1
0, 1, 0
0
1
1
0, 1, 1
0
1
1
1, 0, 0
0
1
1
1, 0, 1
0
1
1
1, 1, 0
1
0
1
1, 1, 1
1
2
3
on average
1 over 2
1
3 over 2
3 numbers into 2 buckets, all 8 choices. Put 2 averages 1 over 2 and put 3 averages 1, the load before each. The totals average 3 over 2, their sum.
where does this come from?
question 2 of the page expected costShuffle different numbers at random. How many pairs stand out of order, on average?
1the move: out of order half the time
the line:
Trading places 1 and 3 pairs each shuffle holding them in order with one holding them out of order, 3 and 3.
shuffle
places 1 and 2
places 1 and 3
places 2 and 3
pairs out of order
1, 2, 3
0
1, 3, 2
yes
1
2, 1, 3
yes
1
2, 3, 1
yes
yes
2
3, 1, 2
yes
yes
2
3, 2, 1
yes
yes
yes
3
in all
3
3
3
9
Each shuffle of 1, 2 and 3, a yes where a pair of places is out of order. 9 over 6 is 1.5.
why it is allowed: A pair is two places. Trading their numbers pairs each shuffle with another, and trading back undoes it. Each two has the pair out of order in exactly one, and both are as likely: chance one half.
2the move: expected counts add
the line:
why it is allowed: The table at line 1 adds two ways: down its last column, 9, and along its bottom row, 3 + 3 + 3. Over 6 shuffles, 9 over 6 is the average count, 1.5, and 3 over 6 three times is the pairs' chances added, 1.5 too. Both add the same yeses, so they agree for any , though the pairs depend on each other. With unequal chances, weight each yes by its order's chance. 2, 1, 3 at 3 over 4 and 1, 2, 3 at 1 over 4 give 3 over 4 both ways.
3the move: one half for each pair
the line:
why it is allowed: By line 2 the expected count adds line 1's one half once per pair.
4the move: count the pairs
the line:
why it is allowed: Let be the expected count, by line 3 half the number of pairs. The first place pairs with the after it, the next with one fewer, down to 1. For 3 places, 2 + 1 is 3 pairs, so 1.5.
5the move: add them the other way round
the line:
why it is allowed: The same numbers in the other order.
6the 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 page on adding up 1 to adds the numbers from 1 to any whole number. They add up to that number times one more than it, halved: 1 + 2 + 3 is 3 times 4, halved, which is 6. In its working, its sum runs from 1 up to its own last number, which it calls . Here that is .
7the move: tidy the bracket
the line:
why it is allowed: is .
8the move: multiply the halves
the line:
why it is allowed: Half of a half is a quarter. For 3, 2 times 3 over 4 is 1.5.
9the move: read it
the line:
why it is allowed: By lines 4 to 7 there are pairs, and line 8 is half that. For 3, 1.5, as line 1 counted.
why it is allowed: The box under this line shows that an average count adds up each piece's chance, at its line 2. Count the th put's looks as one piece for each number already in, a yes when they share a bucket, with chance 1 over 5. Its pieces add to line 1's average, so is the looks averaged over every choice of buckets. The table shows it on 2 buckets, 8 rows, where 5 buckets would need 125.
guess it, then
4the move: take out the fifth
the line:
why it is allowed: Fifths add their tops, as 0 fifths, 1 fifth and 2 fifths make 3 fifths.
guess it, then
5the 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 , so this question's line 4 has on top, and a fifth of that is . For 3, 2 times 3 over 10 is 0.6.
guess it, then
6the move: a ceiling
the line:
why it is allowed: In line 5, is less than . For 3, 0.6 is at most 0.9.
guess it, then
7the move: read it as a bound
the line:
why it is allowed: By line 6.
guess it, then
8the move: a floor
the line:
why it is allowed: In line 5, write half of in place of , no bigger from 2 numbers on by line 10 of the one-bucket question. Half of times , over 10, is . For 3, 0.6 is at least 0.45.
guess it, then
9the move: read it as a bound
the line:
why it is allowed: By line 8, from 2 numbers on.
guess it, then
10the move: ceiling and floor together
the line:
why it is allowed: Lines 7 and 9 bound by the same growth, . At random costs little more than spread in turn, 990 looks against 950 at 100 numbers.
guess it, then
try it on small inputs: over every choice of bucket for each of 3 numbers, 125 in all, the average is