Skip to content

Hash table with chaining

storing

Level 2 of 3

Also called Separate chaining.

fresh numbers

The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from hash table with chaining's own run on the numbers shown.

choose one

question 1

An empty table of 5 buckets puts in 50, 75, 17, 65 and 12, in that order. How many looks do the five puts make in all?

the answer, and why

the answer is C

Each put looks at every number already in its bucket, the remainder after dividing by 5: put by put, 0 + 1 + 0 + 2 + 1, 4 in all.

if you chose another

  • That counts every number before each put, as if all shared one bucket.
  • That counts only 65's 2 looks, but other puts meet numbers too.
  • That counts 1 look for each put into a bucket holding numbers, but 65 meets 2.

new numbersthe test page's numbers

question 2

Which five numbers, put into an empty table in this order, cost the fewest looks?

the answer, and why

the answer is D

Putting in 22, 19, 41, 5, 43 takes no look, the fewest of the four: the fewer numbers share a bucket, the fewer looks.

if you chose another

  • That list takes 1 look, more than 0.
  • That list takes 1 look, more than 0.
  • That list takes 4 looks, more than 0.

new numbersthe test page's numbers

question 3

An empty table puts in 29, 49 and 44, takes 49 out, then puts in 54. How many looks do the five operations make?

the answer, and why

the answer is B

29 finds bucket 4 empty, 0. 49 meets 29, 1. 44 meets 29 and 49, 2. Taking 49 out meets 29, then finds 49, 2. 54 meets 29 and 44, 2. That is 7.

if you chose another

  • That counts the take as a walk of the whole bucket, but it stops at 49.
  • That leaves out the take's 2 looks.
  • That counts the take as 1 look, but it meets 29 before it finds 49.

new numbersthe test page's numbers