What is hashtable?

Palistha
2 min readMay 3, 2022

--

Hashtable is a data structure. The data in the hashtable are stored in key and value pairs.

Key = USA

Value = Washington DC

How is it stored in memory?

The key in the hashtable is used to generate an index where the key and value of the hashtable are stored. The index is generated using a hash function.

For example, Hash Function generates hash value 98214 from the key USA. Now the hash value 98214 is used as an index which stores the key and value pair of hashtable.

Whenever, the key USA is used to generate the hash value, the hash function will always give the same hash value. This means the hash table cannot contain duplicate keys.

Hashing is one way. Which means we cannot get the key USA from the hash value 98214.

We can insert, access, delete the value of the hash table using the keys of those values. So the time complexity of accessing, deleting, and inserting the values in the hash table is O(1).

--

--

Palistha
Palistha

Written by Palistha

Learning and Sharing Everyday

No responses yet