Answer the question
In order to leave comments, you need to log in
Hash table is an associative array of indices and addresses in memory?
I'm studying algorithms and I can't figure out how Hash tables work.
There is some data scattered in memory with certain addresses .... and an associative array where the indexes received by the hash function and the addresses assigned to them in memory are stored. So how then is the performance of Hash tables in books and lessons described as O (1) if we need to use binary search for example to get the address in memory while the indexes (keys) are sorted. log2 from array length...
Answer the question
In order to leave comments, you need to log in
The hash function determines an index in an array.
Accessing an element by index takes O(1)
You pass the key-value to the record "key1" -> "value1
" "value1"
We request the value for "key1" from the map - the hash from "key1" is calculated (got 12), subtracted element 12 from the array - got the value
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question