Posted on 2006-03-23
I'm slightly confused as to one aspect of how hashtables work. I understand that a hashtable is really just an array of key values, which can be turned into numbers using a hash function, which then allows you to map those values to data values.
But, I'm not sure if a hashtable is supposed to be created using one or two arrays. I would think you'd need two arrays to create a hashtable - one for key values and one for data values.
Is this correct? Some websites seem to imply there is only one array, which holds the data values, which are simply located at the hash index of a list of predetermined key values.
I'd think though, that when you perform a lookup, it would need to hash the lookup keyword, then check the keyword array for that index value, and see if the key matches. THEN, it would look up the same hash index in the data array, and return that value.