Fiveable
Fiveable

Hash maps

Definition

Hash maps are data structures that store key-value pairs, where each key is unique. They use a hash function to convert the key into an index in an array, allowing for efficient retrieval and insertion of values.

Analogy

Think of a hash map as a phone book. Each person's name (key) is associated with their phone number (value). When you want to find someone's number, you don't have to search through the entire phone book - instead, you use their name to quickly locate their number.

Related terms

Arrays: Data structures that store elements in contiguous memory locations.

Hash functions: Algorithms that take an input and produce a fixed-size output (hash value).

Collision resolution: Techniques used when two keys produce the same hash value in a hash map.



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.