less than 1 minute read

HashMaps?

  • A HashMaps are a type of map.
  • Maps are collections of key-value pairsthat are searchable.
  • Maps are unordered.
  • Maps store and retrieve data using the keys to identify entries.
  • Keys must be unique. They cannot be changed(=immutable) e.g> <k:A, v:3> <k:A, v:4> CANNOT exist in the same map
  • Values are not unique, and therefore, they can be changed(=mutable) e.g> <k:A, v:3> <k:B, v:3> CAN exist in the same map
  • Maps also sometimes called dictionaries.
  • A real life example of KVpairs is phone numbers and names.
Phone Number = KEY
Name = VALUE

Map ADT

Methods:

- V put(<K, V>)
- V get(K)
- V remove(K)
- int size()
  • SIZE refers to the number of entries, n
  • CAPACITY refers to the length of the backing array, N

Leave a comment