Hash table

related topics
{math, number, function}
{system, computer, user}
{rate, high, increase}
{@card@, make, design}
{style, bgcolor, rowspan}

In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). Thus, a hash table implements an associative array. The hash function is used to transform the key into the index (the hash) of an array element (the slot or bucket) where the corresponding value is to be sought.

Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table after creation). Most hash table designs assume that hash collisions—the situation where different keys happen to have the same hash value—are normal occurrences and must be accommodated in some way.

In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table. Many hash table designs also allow arbitrary insertions and deletions of key-value pairs, at constant average (indeed, amortized[1]) cost per operation.[2][3]

In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.

Hash tables should not be confused with the hash lists and hash trees used in cryptography and data transmission.

Contents

Full article ▸

related documents
Markov chain
Computational complexity theory
Collatz conjecture
Topological space
Recurrence relation
Matrix multiplication
Zermelo–Fraenkel set theory
Peano axioms
Limit superior and limit inferior
Binary search tree
Naive set theory
Elliptic curve cryptography
Inverse function
Finite field
Recursion
Word problem for groups
LR parser
Cantor set
Limit (category theory)
Inner product space
Addition
Calculus
Pi
Numeral system
Pythagorean theorem
Wavelet
Reed–Solomon error correction
Mathematical induction
Scheme (programming language)
Fourier series