AThe slot is one place, but working it out reads every letter.
BEach new letter is read too, 1,000 more.
DThat would be every letter read once for each letter. 1,000 × 1,000 is 1,000,000 reads, and 2,000 × 2,000 is 4,000,000, four times as many. Each letter is read once.
pen and paper
5question 5about 5 minutes
Work out the slot of fig by hand, with base 31 and 13 slots.
Each letter's number.
The value after each letter.
The slot.
a hint
f is the 6th letter of the alphabet.
a worked answer
f is 6, i is 9 and g is 7. After f: 6, which leaves 6. After i: 6 times 31 plus 9 is 195, 15 thirteens, which leaves 0. After g: 0 times 31 plus 7 is 7, which leaves 7. So fig goes in slot 7.
One table is keyed by email addresses of 60 characters, another by documents of 4,096 characters. Each look up opens one slot.
How many characters does one look up read to find its slot in each?
About how many times as long does the second take?
a hint
Use question 1 of the learn page.
a worked answer
By question 1, a method like this one reads each character once: 60 for an email address and 4,096 for a document. 4,096 over 60 is about 68, so about 68 times as long, though each opens one slot. The books' volume two, chapter 16 makes this point.
Question 1: how many letters, , does the method read on a word of letters?7 of 7 shown
1the move: one letter each time round
the line:
time round
letter read
letters read so far
1
c
1
2
a
2
3
t
3
cat: 3 times round, 3 letters read.
why it is allowed: The loop starts at the first letter and moves on one letter each time round, until the last. It never goes back.
2the move: count them
the line:
why it is allowed: By line 1, one letter read for each letter of the word. For cat, 3.
guess it, then
3the move: a ceiling
the line:
why it is allowed: By line 2, is , so at most .
guess it, then
4the move: read the bound
the line:
why it is allowed: By line 3: at most 1 times , at every .
guess it, then
5the move: a floor
the line:
why it is allowed: By line 2 again, is , so at least .
guess it, then
6the move: read the bound
the line:
why it is allowed: By line 5: at least 1 times , at every .
guess it, then
7the move: both together
the line:
why it is allowed: Lines 4 and 6 bound by the same growth, , from above and below.
guess it, then
try it with a small : at , line 2 gives , which you can work out by hand