DSA 5 Hash Table - morgan-401-advanced-javascript/seattle-javascript-401n14 GitHub Wiki

Read Intro to Hash Tableslink

  • Hash - A hash is the result of some algorithm taking an incoming string and converting it into a value that could be used for either security or some other purpose. In the case of a hashtable, it is used to determine the index of the array.

  • Buckets - A bucket is what is contained in each index of the array of the hashtable. Each indicie is a bucket. An indicie could potentially contain multiple key/value pairs if a collision occurs.

  • Collisions - A collision is what happens when more than one key gets hashed to the same location of the hashtable.

  • Hashtables are a data structure that utilize key value pairs. This means every Node or Bucket has both a key, and a value.

  • The basic idea of a hashtable is the ability to store the key into this data structure, and quickly retrieve the value. This is done through what we call a hash. A hash is the ability to encode the key that will eventually map to a specific location in the data structure that we can look at directly to retrieve the value.

  • Since we are able to hash our key and determine the exact location where our value is stored, we can do a lookup in an O(1) time complexity. This is ideal when quick lookups are required.

Watch what is a hash table? Read basics of hash tables Skim hash table wiki