Skip to content

Latest commit

 

History

History
42 lines (22 loc) · 1.66 KB

README.md

File metadata and controls

42 lines (22 loc) · 1.66 KB

Hash Table

See code examples by clicking here.

Definition

Data structure useful for mapping keys to values which, on average, provides very fast lookups, insertions and deletions.

Imagine that we are working on a problem that requires us to store [key: value] pairs. Let's assume that both keys and values are integers. We could simply use an array of size n, storage[n], where the keys could be represented by the array indexes and the values would be stored at these positions as seen below:

storage[key] = value

where key is an integer in the range 0 to n-1.

Now, what if these keys are very large numbers or not numbers at all? We could very well have strings as keys datatype. Then, it would not be possible to directly use these keys as indexes, and they would have to go through some kind of process in order to convert these keys into integers able to be used as indexes for storage[n]. The said process is called hashing and it uses special functions called hash functions to perform the necessary convertions. In a simplified way, then, a Hash Table is basically a combination of a hash function and an array like storage[n], for instance.

Example

... Phonebook w/ company #

Pseudocode

...

Time complexity

...

Space complexity

...

Collision resolution techniques

...

References