StudyGraph
Computer Science Explainer

Why hash tables find things in O(1)

How can a table of a million items find one key in a single step?

Lesson notes

Key points

Definitions

Hash table
A data structure mapping keys to values by computing an array index from each key.

Takeaway: Hashing turns a key into an array index, giving O(1) average access.

Quick check: What gives a hash table its O(1) average lookup?
  1. Keeping keys sorted
  2. Computing the index directly
  3. Using a linked list

Hash tableHash functionO(1) averageO(1) vs O(n)

Lessons like this, for your syllabus.

Short narrated study videos written for your course, level and exam. Free to start.

Get lessons for your own syllabus