-
Notifications
You must be signed in to change notification settings - Fork 0
Hash Tables
Devrath edited this page Feb 13, 2024
·
5 revisions
- Hash Tables are used for very fast
insertion
andretrieval
of data. - The adding and retrieval of data happens in constant time.
- It is the collection of
key and value
pairs.-
Key
can be any type of object and necessarily need not have to be anumber
. -
Value
can also be any type of object.
-
- Consider a collection of records, where the
user
object consists of properties likename
,age
,email
- Here we can use the
email
field as thekey
for each object. - You pass a
key
as anemail
to the HashTable collection, It will return the corresponding employee.
- We know that in
arrays
, when we pass the index we can get the value in constant time. - But here we can pass only the
integer
as a key and we can't pass any other type here.