Interview Question: What is a hashmap?

Viewed 38123

I was asked this in an interview: "Tell me everything you know about hashmaps."

I proceeded to do just that: it's a data structure with key-value pairs; a hash function is used to locate the element; how hash collisions can be resolved, etc.

After I was done, they asked: "OK, now explain everything you just said to a 5-year-old. You can't use technical terms, especially hashing and mapping."

I have to say it took me by surprise and I didn't give a good answer. How would you answer?

5 Answers
Related