FirstHack 2026 — a 36-hour online hackathon built for first-year students.•₹1,00,000 prize pool•22 Oct – 4 Nov•Open to every branch and every stream•Certificate for every team that submits•3 rounds•FirstHack 2026 — a 36-hour online hackathon built for first-year students.•₹1,00,000 prize pool•22 Oct – 4 Nov•Open to every branch and every stream•Certificate for every team that submits•3 rounds•
O(1) lookup, how the hash function decides everything, and what to do when two keys collide.
13 min read·Lesson 6 of 6·Pro
Skipping the search entirely
Every structure so far searches: a list walks, a tree compares. A hash table does neither. It computes where the item should be.
C
int table[10];
int key = 47;
int index = key % 10; /* 7 */
table[index] = key;
Storing and finding are both one arithmetic operation. That is O(1), and it does not grow with n. Nothing else on your syllabus does this.
The catch
47 % 10 is 7. So is 37 % 10, and 107 % 10. Three different keys, one slot. That is a collision, and it is not a rare accident you can design away.
The rest of this lesson is Pro
The free lessons of Data Structures in C finish what
they start — read those first if you have not. This one goes further, and it
is part of the paid half.
A pass opens the paid lessons of every course, the mock test papers
and the company-wise series. It ends on its own date; nothing renews by itself.