Nepedia
Back to Discover
Independent Reader
💻

Hash table

technology Maturity 7-9 Next article →

Computers need fast ways to find data. A hash table is a smart tool for this. It works like a digital dictionary.

A hash table uses a hash function. This is a rule that turns a key into a number. This number is called an index. The index tells the computer which slot to use. The computer stores a value in that slot. This makes finding things very quick.

Sometimes, two different keys get the same index. This is called a collision. Computers have two main ways to fix this. One way is called separate chaining.

Hash table 5 0 1 1 1 1 1 LL
Hash table 5 0 1 1 1 1 1 LL

This method links items together in a chain. The computer follows the chain to find the right one.

Another way is called open addressing.

Hash table 5 0 1 1 1 1 0 SP
Hash table 5 0 1 1 1 1 0 SP

This method looks for the next empty slot.

If a table gets too full, it can slow down. This is measured by the load factor. To stay fast, the computer may resize the table. This is called rehashing. Many programming languages use these tools every day.

166 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (4)
File:Hash table 3 1 1 0 1 0 0 SP.svg
Hash table 3 1 1 0 1 0 0 SP.svg
File:Hash table 5 0 1 1 1 1 1 LL.svg
Hash table 5 0 1 1 1 1 1 LL.svg
File:Hash table 5 0 1 1 1 1 0 LL.svg
Hash table 5 0 1 1 1 1 0 LL.svg
File:Hash table 5 0 1 1 1 1 0 SP.svg
Hash table 5 0 1 1 1 1 0 SP.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.