Video
A video that accompanies this page is here....
Limitations
Like all structures, hash tables also have limitations:
- Not sorted (this does not impact search, but does impact traversal)
- Order of keys (as entered) is not preserved -- thus traversal order would be unspecified
- Searching for a range (e.g., from key 10 to 20) is not efficient (because keys are unsorted)
Advantages
Hash tables do two fundamental things:
- Setting a given key with its associated value, e.g., "put(key, value)"
- Searching for a key and returning the associated value, e.g., "get(key)"
They perform these operations at the highest possible efficiency of O(1).
If a problem needs fast key (key-value) searching, then hash tables are the way to go.