I\'m quite confused about the basic concepts of a Hash table. If I were to code a hash how would I even begin? What is the difference between a Hash table and just a normal
The question, I believe, is answered quite clearly and in many different ways by now.
I would just like to add another perspective (which may confuse a new reader as well)
At a level of least abstraction, arrays are just contiguous block of memory. Given the starting address (startAddress
), size (sizeOfElement
) and the index
of a single element, the address of element is computed as:
elementAddress = startAddress + sizeOfElement * index
The interesting thing to note here is that arrays can be abstracted/viewed as hash tables with index
as key and the above function as a hash function which calculates the location of a value in O(1)