FAQ: Hash Maps: Conceptual - Basic Hash Maps

This community-built FAQ covers the “Basic Hash Maps” exercise from the lesson “Hash Maps: Conceptual”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

Complex Data Structures

FAQs on the exercise Basic Hash Maps

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

What will we do if for different keys we have same hash value ?

1 Like

Can someone explain how they go from 8 -->0 , 2–>2 , 3–>3 and 5 -->1 in the text example?

                             Hash         Hash mod 4	     Release Year
People's Instinctive ...     	8	         0              	1990
The Low End Theory	            2	         2	                1991
Midnight Marauders	            3	         3	                1993
Beats, Rhymes and Life	        5	         1	                1996


I guess I didn’t know that if there wasn’t enough to divide into a number, it would return the number.

2 /4 = 0 with remainder 2. I get it.

If we want to store keys and values. Can’t we just use dictionaries instead of Hash tables? I mean even dictionaries can store one value for one key and it is easier to setup.

8%4 = 0, 2%4 = 2, 3%4 = 3, 5%4 = 1. Hash mod 4, that’s why I think need operation % 4

Yes, the hash must be taken mod (number of bins.)

If you mean Python dictionaries, they are implemented using hash tables already- it’s just that you don’t have to do all that bit because Python did it for you :slight_smile: