LOGBOOK

HELP

Quiz Entry - updated: 2026.11.26

What is open addressing, and how does linear probing find a cell for a colliding entry?

Open addressing stores every entry in the array itself: on a collision it searches for another free cell. Linear probing tries the next cell, then the next, wrapping around at the end, until it finds an empty one.

With open addressing there are no lists: one cell holds at most one entry. The sequence of cells tried for a key is its probe sequence. Linear probing uses the simplest one:

h(k), h(k)+1, h(k)+2, … (all mod N)

get(k) follows the same sequence: start at h(k) and step forward until it finds k (hit) or an empty cell (k is not in the table, because put would have stopped there). At every cell it compares the stored key with k using equals. The address depends only on the key; the value never plays a role.

Variations change the step:

  • alternating: +1, −1, +2, −2, … This softens the problem a little but does not solve it: collisions still pile up around one hotspot.
  • quadratic probing: +1, +4, +9, …, i.e. +j² after the j-th collision, so the probes jump away from the hotspot in growing steps.

Pro: no extra structures, and stepping through neighbouring cells is cache-friendly. Con: the table can fill up (at most N entries), and runs of occupied cells tend to grow, which makes later probes longer.

Go deeper:

  • doc Linear probing — the probe sequence, clustering, deletion and its expected cost.

From Quiz: ADS / Sets, Maps and Hash Tables | Updated: Nov 26, 2026