FAQ: Hash Maps: Conceptual - Hash Map Methodology

This community-built FAQ covers the “Hash Map Methodology” 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 Hash Map Methodology

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!

1 Like

If the goal of a hashing function is to produce an array index as an output, it should mean that the output of a hashing function should be unique(since two different keys cannot be stored in the same array index). However, why is then “adding the number of vowels in a word” a hashing function?

I mean, there can be two different words, like “coat” and “truce,” which has the same number of vowels. However, the hashing function output for both the words would be 2 in this case.

It would be great if someone could kindly answer this query of mine.

1 Like

How are Hash Maps and Dictionaries different? Aren’t dictionaries enough for key value pair data entry and access? If so, why do we need Hash Maps? I’m getting really confused about this, would appreciate any clarification.

You may have to do some digging to be sure but as far as I am aware Python’s dictionaries are currently implemented using one form of hash map (though the terminology can be a bit hazy). You could use your hash map to create your own dictionary class if you wished but there are other ways to get a working dictionary of this form. Practically in Python you’d be using the built-in for the most part but knowing how to implement your own is worthwhile. You may find you have a need for a specialised implementation one day or have the need to create one in a different language (though you’d likely use one that is already available).

You’d be learning about these structures in this course but for a higher level language like Python you will find thay many of them already in use, such as doubly linked lists, heaps and hash maps etc. which are either built into the language or are available from standard libraries.

3 Likes

Thank you ! I did dig around and found out that Hash Maps were used to implement Dictionary in Python, so a dictionary is essentially a Hash Map. It is clear to me now!
And learning about Hash Maps was a blast! Really glad I started this course :slight_smile:

1 Like

I have the same doubt too! Can someone please clarify this doubt?

Hashing functions aren’t perfect, a fixed sized hash will always have the possibility of collisions, what you want though is a very low probability of collisions. A good hashing function should minimise the number of collisions, the number of vowels in a word would be an example of a poor hashing function.

For a hash map you would probably need some additional coding to deal with collisions for this reason (this is even more important in OOP where object equivalence may be more common than expected). I’m sure it’ll pop up in due course.