Amazon Interview Question Software Engineer / Developers
0of 0 votesWhat is hash map? How do you insert an element into it? what happens when i insert another value for the same key and I do get for that key? What is queue? what is priority queue? should priority be integral? can they be string comparisons as priority?
Country: United States
Interview Type: Phone Interview

1) Hash_map is a Hashed Associative Container that associates objects of type Key with objects of type Data.
- Anonymous on November 06, 2011 Edit | Flag ReplyFinding an element in a hash_map by its key is efficient, so hash_map is useful where the order of elements is irrelevant.
If order of elements is important we use STL Maps.
2) Elements in a hash map are organized in buckets. The value of a deterministic hash function with input as key, determines the location for storing a <key, value> pair.
3) STL hash maps can have only 1 value associated to a specific key. The original value for a key is over-written when you insert another value for the same key. If we wish to associate different values with same key, we should use STL MultiMaps.
4) Queues are FIFO (First in First Out) based Data structures.
5) priority queue: elements are pulled highest-priority-first
6) Priority need not be integral. There can be string comparisons as priority