Log in from a computer to take this course

You'll need to log in from a computer to start Introduction to Algorithms and Linear Data Structures in Swift. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

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.

Instructions

1.

Create a HashTable instance, animalSoundsHashTable. We’ll use the hash table data to store animal sounds. Give it an array size of 15.

2.

Assign the following key-values pairs to animalSoundsHashTable:

  • Key: “Dog”, Value: “Bark”
  • Key: “Cat”, Value: “Meow”
  • Key: “Lion”, Value: “Roar”
3.

Retrieve the location for each of the sounds in animalSoundsHashTable and print them to the terminal.

4.

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?

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?