3.3.5 · D1Hashing

Foundations — Deletion in open addressing — tombstone markers

1,818 words8 min readBack to topic

This page builds every word and symbol the parent note leans on, from absolutely nothing. If you have never seen a hash table, start here and read top to bottom — nothing below is used before it is drawn.


0. The array — the one shelf everything lives on

Before any hashing, you need the picture of an array: a straight row of numbered boxes, side by side, each holding one thing.

Figure — Deletion in open addressing — tombstone markers

1. The key — the thing we store


2. The hash function — turning a key into a starting box

We can't search all boxes for every key — that would defeat the point of a fast table. We need a rule that jumps straight to a likely box. That rule is the hash function.

Answer these before moving on:

Why does every index formula end in ?
To keep the result a valid box index inside the array (and to wrap past the end back to ).

3. Collision — two keys wanting the same box


4. Open addressing vs. separate chaining — where do overflow keys go?

There are two families of fixes for collisions. The parent lives in open addressing; knowing the other one sharpens what "open" means.

Figure — Deletion in open addressing — tombstone markers

Because open addressing keeps everything in the one array, deleting a key leaves a gap inside the array itself — and that gap is the whole problem the tombstone solves. Separate chaining never has this issue.


5. Probing and the probe sequence

Since a colliding key can't use its first box, it tries others in a fixed, repeatable order. That ordered list of boxes is the probe sequence.

Figure — Deletion in open addressing — tombstone markers

6. The three slot states — the heart of the topic

Every box is always in exactly one of three states. The parent's whole argument turns on telling them apart.

The single most important distinction — and the reason tombstones exist:


7. Load factor — how full is the shelf?

To talk about cost, we need one number for "fullness."

Self-test:

If and boxes are OCCUPIED, what is ?
If additionally box is a tombstone, what is ?

8. How these foundations feed the topic

Array and index j

Table size m

Key k

Hash function h of k

Modulo mod m

Collision

Open addressing

Probe sequence h k i

Three slot states

Search stops at EMPTY invariant

Tombstone deletion

Load factor and alpha eff


Equipment checklist

Test yourself — you should be able to answer each without looking up.

What is an array index, and where does counting start?
The address of a box in the row; counting starts at .
What does stand for?
The table size — the number of boxes in the array.
What does a hash function produce?
A starting box index in for key .
Compute .
.
Why does every probe formula end in ?
To keep the index inside the array and wrap the last box back to .
What is a collision?
Two different keys hashing to the same box.
Difference between open addressing and separate chaining?
Open addressing stores every key inside the array; separate chaining hangs colliding keys off linked lists.
Write the linear-probing sequence formula.
.
What are the three slot states?
EMPTY, OCCUPIED, DELETED (tombstone).
What opposite messages do EMPTY and DELETED send to a search?
EMPTY says "stop, not here"; DELETED says "keep probing."
Define the live load factor .
.
Define .
.

Connections

  • Parent: tombstone deletion — where all of this is put to work.
  • Hash Functions — the that starts every probe.
  • Open Addressing — the family this topic belongs to.
  • Linear Probing — the specific probe rule used above.
  • Separate Chaining — the alternative where deletion is trivial.
  • Load Factor and Rehashing — where and drive rebuilds.