HashTable Key vs Value Fetch Complexity
2 answers
Getting a hash key is O (lk) in key length because you have to use it, but n/k
it is assumed to be constant for any hash table. This is usually called O (1) since it is independent of n
, but not strictly O (1) unless the key size is fixed.
But getting the hash value would require iterating over the whole table looking for it, assuming you didn't preorder it (you can create hash tables that can support binary search too for O (log (n)), but this is unusual ).
+4
source to share