Think of a library. If you know the title of the book, you can go to the isle containing all the books starting with the first letter of your title, walk down and find your book, assuming all the books are in alphabetical order. This takes relatively less time, so it’s O(1), meaning you almost immediately find your book. This is much easier than knowing the title of the book, but all the books are put on the shelf randomly, which means you have to go through however many books there are, say N number of books, and look through each book one by one. This would take O(N) time.
I’m part way through the tutorial, and have a constructor for the class, a hash(key) method and a set(key, value) method.
I find doing these tutorials is the best way for me to learn about what is really happening under the hood.
I’m creating hashes by converting each letter in the hash(key) key parameter to UTF-16 code, and then adding those codes together to get a sum. The sum is the key in my hash table. Of course, there may be collisions or two keys that have the same sum. For instance, “name” and “mean”. In this case, I store the entire key-value pair in an array and push it into the slot on my hash table. 🔐 🔑
That’s all I’m up to for now, and I will continue implementing this!