Searching and Hashing

It is important to understand what search is and when it is appropriate. This page explains sequential and binary search, and their implementation. There is also the matter of hashing as a storage and search technique. In so doing, we introduce the unordered map and how to implement a map abstract data type using hashing. Read Sections 6.1-6.5. You may also find Sections 6.6-6.11 useful for practice.

7. Discussion Questions

  1. Using the hash table performance formulas given in the chapter, compute the average number of comparisons necessary when the table is

    • 10% full

    • 25% full

    • 50% full

    • 75% full

    • 90% full

    • 99% full

    At what point do you think the hash table is too small? Explain.

  2. Modify the hash function for strings to use positional weightings.

  3. We used a hash function for strings that weighted the characters by position. Devise an alternative weighting scheme. What are the biases that exist with these functions?

  4. Research perfect hash functions. Using a list of names (classmates, family members, etc.), generate the hash values using the perfect hash algorithm.