Suggest an editImprove this articleRefine the answer for “How does a hash table store data?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A **hash table** stores data as **"key -> value" pairs**, using an **array** and a **hash function** that determines which slot an element is stored in. **Key point:** a hash table is essentially an array plus a hash function plus a way of handling collisions, which allows data to be found by key quickly without a full scan.Shown above the full answer for quick recall.Answer (EN)ImageA hash table stores data as **"key -> value" pairs**, using an **array** and a **hash function** that determines which slot an element is stored in. ## Step by step 1. When an element is added, the **hash of the key** is computed: ```javascript index = hash(key) % N ``` where `N` is the size of the array. 2. The element is placed in the slot with that index. 3. On lookup or removal, the same hash function is used: the index is computed from the key, and the element is accessed directly. ## Example Let the table size be 10, and `hash("dog") = 23`. Then `23 % 10 = 3`, and the pair `("dog", "animal")` is stored in slot #3. ## If there is a collision (two keys give the same index) - with **chaining**, the slot stores a list of all elements with that index; - with **open addressing**, the table searches for the next free slot. So a hash table is essentially an **array + hash function + a way of handling collisions**, which allows data to be found by key quickly without a full scan.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.