CMPS 144L Spring 2020
Lab #12 (Week of May 11): Hash Tables

CMPS 144L Lab Activity
Hash Tables (Open Addressing, Linear Probing)

  +------------+
0 | Gorn (8)   |
1 |            |
2 |            |
3 | Picard (3) |
4 | Worf (4)   |
5 | Troi (3)   |
6 |            |
7 |            |
8 | Borg (8)   |
9 | Spock (8)  |
  +------------+ 
Consider the hash table to the right (where only keys are shown, with home addresses in parentheses), in which linear probing is used for resolving collisions.

1. What is the packing density (also called load factor) of this table?

2. Given the table's contents, and assuming that each key therein is equally likely to be the subject of a search, what is the expected number of probes (i.e., accesses to cells) performed in a successful retrieval of a record? (Your answer can be in the form of a rational number, i.e., a fraction having integer numerator and denominator).

3. Given the table's contents, and assuming that each of its ten addresses is equally likely to be the home address of a key that is the subject of a search, what is the expected number of probes in an unsuccessful retrieval (i.e., a search for a key that is not present)? (Again, your answer can be a rational number.)

Compare this figure with the number of probes we would expect (according to the analysis done in class) in a table having this one's packing density. Is it significantly greater, significantly less, or about the same?

4. Indicate how the table would change as a result of inserting Horta, which has 4 as its home address.

5. When using linear probing as a collision resolution strategy, we must ensure that there are no unoccupied cells between the home address of a key and the location that it occupies (including the home address itself). Explain why this is so and indicate what changes should be made to the table if the Picard record were removed. How about if Worf were removed?