Suggest an editImprove this articleRefine the answer for “What is a hash table?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A **hash table** is a data structure that stores **(key → value)** pairs and allows elements to be found **almost instantly**, in **O(1)** time on average. **Key point:** hash tables underlie caches, dictionaries, databases, and many algorithms where fast lookup by key matters.Shown above the full answer for quick recall.Answer (EN)ImageA **hash table** is a data structure that stores **(key → value)** pairs and allows elements to be found **almost instantly**, in **O(1)** time on average. ## How it works 1. Each key passes through a **hash function**, which turns it into a number, the **hash**. 2. This hash points to which "slot" (index) of the table the value should be written to. 3. When looking up the same key, the hash function computes the same index, and the element is found quickly. ## The collision problem Sometimes different keys produce the same hash, this is a **collision**. It is resolved with: - **chaining**, the slot stores a list of all elements with the same hash, - **open addressing**, searching for the next free slot. ## Advantages - fast access to data, O(1) on average; - simple insertion and removal. ## Example In Python this is a **dictionary (dict)**, in Java, **HashMap**, in C++, **unordered_map**. Hash tables underlie caches, dictionaries, databases, and many algorithms where fast lookup by key matters.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.