Member-only story
The Basics of Hash Table
Hash table is fundamentally a data structure that offers fast insertion, lookup and deletion
Those of us who’ve lived reasonably long enough must know or at least have seen a yellow page. Yup! You’re right. It is the thick yellow book containing directories of businesses and their phone numbers. This enables us to search for a business that sells what we need and contact them.
(I don’t think Gen Z and the next generations after that would come to know about this thick yellow book. 😆)
A directory of phone number is usually alphabetically ordered, so we know where we can start our search. Once we find the business name that we want, we can grab the phone number and call them. You get the idea. 💡
Hash Table
What if I tell you that a yellow page or a phone book is an implementation of hash table? You bet! 🐴
Hash table is essentially an array coupled with a hash function. It is commonly used to store key-value data, for example, businesses and their phone number, students and their grades, items and their prices and many more, in an unordered…