data-structures · intermediate · ~15 min

Lookup with linear probing

Search an open-addressing table the way insertion laid it out.

Challenge

With the same convention (0 = empty), implement int table_find(const int *table, int cap, int start, int key) returning the index where key is stored — probing forward from start — or -1 if an empty slot is hit first or the table is exhausted.

Starter code

int table_find(const int *table, int cap, int start, int key) {
    /* TODO */
    return -1;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.