Brainlag
  1. C
  2. Advanced
28/38 lessons

Hash tables

55 min4 exercisesPremium

Build a hash table in C: a hash function picks a bucket, collisions chain into linked lists, and lookups skip almost everything. Then count words with it.

The skill
Build a chained hash table that stores its own copies of string keys and finds, updates and removes entries quickly.
You make
A word counter, a fixed table of player tags and a game inventory that adds and removes items by name.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 27 Stacks and queues. Free to try: C Foundations and the playground.

Step 1 of 8
exercise_1.c

You've reached the good stuff.

4 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

C, 32-bit: int and pointers are 4 bytes