Database Systems · Extendible Hashing Worked Insertions
Worked sequence A — bucket capacity b = 2
Hash values are 4-bit strings. Insert in this order: .
Step 0 — initial state
, directory has entry, one empty bucket with .
g = 0
dir: [0] B0 (l=0): {}
Step 1 — insert 0101
⇒ index 0. has room (0 < 2). Insert.
g = 0
dir: [0] B0 (l=0): {0101}
Step 2 — insert 1100
Index 0 again. now has 2 keys = capacity. Insert succeeds (2 ≤ 2).
g = 0
dir: [0] B0 (l=0): {0101, 1100}
Step 3 — insert 0110
Index 0. is full (2 keys). ⇒ double directory to (2 entries), then split.
- Directory after doubling:
[0]→B0, [1]→B0(both point to the same bucket). - Split on bit 1 (since ):
- 0101 → bit1 = 0 →
- 1100 → bit1 = 1 →
- 0110 → bit1 = 0 →
- New local depths: for both.
g = 1
dir: [0] B0 (l=1): {0101, 0110}
[1] B1 (l=1): {1100}
Step 4 — insert 1010
First bit of 1010 is 1 → index 1 → . has 1 key, room for one more. Insert.
g = 1
dir: [0] B0 (l=1): {0101, 0110}
[1] B1 (l=1): {1100, 1010}
Step 5 — insert 1110
First bit = 1 → , which is full. ⇒ double directory to (4 entries), then split .
- Directory after doubling:
[00]→B0, [01]→B0, [10]→B1, [11]→B1. - Split on bit 2:
- 1100 → bit2 = 1 →
- 1010 → bit2 = 0 →
- 1110 → bit2 = 1 →
- New local depths: for both. keeps .
g = 2
dir: [00] B0 (l=1): {0101, 0110}
[01] B0 (l=1): {0101, 0110}
[10] B10 (l=2): {1010}
[11] B11 (l=2): {1100, 1110}
Step 6 — insert 0100
First bits of 0100 are 01 → index 01 → , which is full ({0101, 0110}). ⇒ split only, no doubling.
- Split on bit 2 (the 2nd bit from the left, not the directory prefix): 0101 → bit2 = 1, 0110 → bit2 = 1, 0100 → bit2 = 1. All three keys go to ; is created empty. Both new buckets get .
g = 2
dir: [00] B00 (l=2): {}
[01] B01 (l=2): {0101, 0110, 0100} <- 3 keys > capacity 2
[10] B10 (l=2): {1010}
[11] B11 (l=2): {1100, 1110}
- is still over capacity, so repeat from step 4 (cascading split). ⇒ double the directory to (8 entries), then split on bit 3: 0101 → 0 and 0100 → 0 go to ; 0110 → 1 goes to . Both get .
g = 3
dir: [000] B00 (l=2): {}
[001] B00 (l=2): {}
[010] B010 (l=3): {0101, 0100}
[011] B011 (l=3): {0110}
[100] B10 (l=2): {1010}
[101] B10 (l=2): {1010}
[110] B11 (l=2): {1100, 1110}
[111] B11 (l=2): {1100, 1110}
Step 7 — insert 1011
First 3 bits = 101 → , which has 1 key. Insert.
g = 3
dir: [000] B00 (l=2): {}
[001] B00 (l=2): {}
[010] B010 (l=3): {0101, 0100}
[011] B011 (l=3): {0110}
[100] B10 (l=2): {1010, 1011}
[101] B10 (l=2): {1010, 1011}
[110] B11 (l=2): {1100, 1110}
[111] B11 (l=2): {1100, 1110}
Final state of sequence A: , 5 buckets ( empty with ; , with ; , with ). Every bucket has ≤ 2 keys. ✔ Invariant check: entries per bucket .
Sequence A summary table
| Insert | before | index | bucket | full? | action | after | |
|---|---|---|---|---|---|---|---|
| 0101 | 0101 | 0 | 0 | B0 | no | insert | 0 |
| 1100 | 1100 | 0 | 0 | B0 | no (1→2) | insert | 0 |
| 0110 | 0110 | 0 | 0 | B0 | yes | double + split | 1 |
| 1010 | 1010 | 1 | 1 | B1 | no | insert | 1 |
| 1110 | 1110 | 1 | 1 | B1 | yes | double + split | 2 |
| 0100 | 0100 | 2 | 01 | B0 | yes | split B0 (all keys go to B01), B01 overflows: double + split | 3 |
| 1011 | 1011 | 3 | 101 | B10 | no | insert | 3 |