Now that we have all of the functionality of a hash table, it’s time to review what we’ve learned. Use what you know about hash tables to record animal sounds.
animalSoundsHashTable. We’ll use the hash table data to store animal sounds. Give it an array size of 15.
Assign the following key-values pairs to
- Key: “Dog”, Value: “Bark”
- Key: “Cat”, Value: “Meow”
- Key: “Lion”, Value: “Roar”
Retrieve the location for each of the sounds in
animalSoundsHashTable and print them to the terminal.
Congratulations, you implemented a fully-functional hash table! Some things to consider:
Are there any other ways of handling collisions besides separate chaining? What would be the advantages or disadvantages of a method of avoiding separate chaining? What are some disadvantages to using hash tables?