Introduction to Hash Table
Hash tables are very efficient. Let’s say that we want to look up a specific person in an array: we would have to walk through every item to look for that person! The space complexity would be O(n), as space depends on the size of the array.
To look things up way more efficiently, you can use hash tables! Hash tables are made up of two parts: an object with the table where the data will be stored, and a hash function (or mapping function). This function creates a mapping by assigning the input data to a very specific index within the array! This function takes a key, and always returns the same index for the same key! If we would run the same key through the function twice, it gives us the same index.