Just wondering if someone can help me answer a most likely stupid question. When using Hash tables why would we hash a key and then add it to an array instead of just adding the key to the array if there is no need to worry about the privacy of that key.
Hello, @bit0750166738, and welcome to the forums.
Hashing the key, and converting it to an index where our data gets stored in the array makes retrieving the data much faster and more efficient. Rather than starting at the beginning of the array, and checking each element until we find the key we’re looking for, we use the same hash value (converted to an array index) to simply retrieve the data at that index.
Okay I get it, as I thought I was being stupid. I was thinking of it as the index is the key you look for rather than the index just being the index you search. Thankyou.