HashMaps basics

Written on November 19, 2023

Basic explanation of hash maps and various nuances


Definition: Hashmaps is a data structure that is structured as a key-value pair. It is also known as a dictionary, map, or associative array.

Common operations

  • Access
  • Set
  • Remove
  • Traverse/Search
    • For a key
    • For a value

Big O

Action Time Space
Access O(1) O(1)
Set O(1) O(1)
Remove O(1) O(1)
Traverse/Search
For a key O(n) O(1)
For a value O(n) O(1)