0Pricing
C Academy · Lesson

Insert, Lookup, Delete

Core operations.

The Three Core Operations

Every hash table supports three operations: insert, lookup, and delete. With a good hash and reasonable load factor, all three run in average O(1) time.

We will build a chaining-based table step by step.

The Table and Node Types

We define a node holding a copied key string and an integer value, plus a table struct holding the bucket array and its capacity.

#include <stdio.h>

typedef struct Node {
    char *key;
    int value;
    struct Node *next;
} Node;

typedef struct {
    Node **buckets;
    unsigned capacity;
    unsigned size;
} HashTable;

int main(void) {
    printf("types defined\n");
    return 0;
}

All lessons in this course

  1. Hash Functions
  2. Collision Handling
  3. Insert, Lookup, Delete
  4. Resizing and Load Factor
← Back to C Academy