Hash table

associates data values with key values - a lookup table From Wikipedia, the free encyclopedia

Hash table
Remove ads


A hash table is a type of tool for storing information. In computer science, these tools for keeping track of information, or data, are called data structures. A hash table is a data structure that uses a hash function to keep track of where data is. Each piece of information to be stored has a name, which is called a key. For example, a key might be a person's name. Each name is matched up to one piece of data called a value, like the person's telephone number.

Quick Facts Type, Invented ...
Remove ads
Thumb
A small phone book as a hash table

The data is kept in another data structure called an array, which is like many boxes, or buckets, in a column to hold data. Each box has a number starting from 0 and counting up.

The idea behind a hash table is to find the box for a value using only its name. This means that no matter how many boxes there are, one can find information quickly by its name. It is very fast to use the box of an array by its number. A hash function reads a name and gives back a number. A hash table uses a hash function to find a box number for a name.

A good hash table will always find information at the same speed, no matter how much data is put in. A lot of hash tables also let the user put key/value pairs (a name and its data) in and take them out at the same speed.[2]

Because of this, hash tables can often find information faster than other tools, such as search trees or other table lookup structures. As a result, they are used in many kinds of computer software. They are used most often for associative arrays, databases, caches, and sets.

Remove ads

References

Loading content...
Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads