Open the editor

Computer science · University

Hash Table Slides

Free animated slides, ready to teach: 6 slides where every step appears on a click and the diagrams move. Play them right here, present them full screen, or copy them into your account to edit.

A real Tracé deck playing in your browser. No account needed.

What the lesson covers

A hash table stores items in an array of buckets, and a hash function turns each key into a bucket number. Students insert keys with h(k) = k mod 7, handle a collision by chaining and see why lookups take constant time on average.

The slides, one by one

1 Hash tables

Compute where it goes

How does a dictionary find a word without searching every entry?

2 The hash function chooses the bucket

h(k) = k \bmod 7

33 and 47 both land in bucket 5

3 Lookups stay fast while buckets stay short

\alpha = \dfrac{n}{m} = \dfrac{\text{items}}{\text{buckets}}

Resize when α passes about 0.75

4 Inserting into a hash table

A table has 7 buckets and h(k) = k mod 7. Insert 23, 47, 10 and 33. Where does each go, and what is the load factor?

→ Remainder on division by 7; chain when a bucket is taken

23 = 3 \times 7 + 2 \to 2
47 = 6 \times 7 + 5 \to 5
10 \to 3,\quad 33 = 4 \times 7 + 5 \to 5
\alpha = 4 / 7 \approx 0.57

Buckets 2, 5, 3 and 5 (chained after 47); load factor ≈ 0.57

5 Quick check

With h(k) = k mod 7, which bucket does 50 go in?

  • 1
  • 7
  • 0
  • 50
Show the answer

1

50 = 7 × 7 + 1, so the remainder is 1.

6 What to remember

Hash function: key → bucket number

Collisions: two keys, one bucket

Chaining keeps a list per bucket

Average lookup O(1) at low load factor

Challenge: Why is k mod 10 a poor hash function for keys that are all multiples of 10?

Every slide is built click by click: text, formulas and pictures come in one step at a time, so the class follows the reasoning instead of reading ahead. Graphs with sliders can be dragged live while you present.

Make your own version with AIChange the level, the numbers or the language: type the topic and get a new deck that moves in about 30 seconds. Free, no account needed.

Questions teachers ask

Why are hash table lookups so fast?

The hash function computes the bucket straight from the key, so there is no searching through the whole table. With a good hash and a load factor kept below about 0.75, each bucket holds only one or two items, so lookups take O(1) time on average.

Are these slides really free?

Yes. Watch them on this page or present them full screen with no account. Making your own copy to edit is free too.

Can I change the slides before my lesson?

Yes. Press "Make my own copy" and the deck becomes one of your projects in the Tracé editor, where you can change the text, the numbers, the colours or the order of the clicks.

Do they work on a classroom projector or an interactive whiteboard?

Yes. They run in the browser on any laptop, so anything that shows your screen works. Press the right arrow or click to go to the next step.