Data Structures

  1. Hash Map: A data structure that relates (or 'maps') a key with a value, each of which could be a number, string, object, etc.

    A key is mapped to a value by using a hash function, which applies a mathematical calculation to the key and returns a numerical value. This value is then used as an index to a hash table, where the key's associated value is stored.

    Because a hash function returns 'almost' unique values, there is a slight chance that two different keys will produce the same hash function result. As such, the hash map might resort to storing the values of the two keys in a list. That is, the hash table is an array of lists.

    The advantage of hash maps is that, when we search for a value based on a given key, we can find it in constant time because the underlying data structure is an array.