1. Gyanastra
  2. Database Systems
  3. Extendible Hashing with Last-Bits Keys, Overflow and Deletion
  4. The idea in one paragraph
Free lesson, no account needed 4 min read

Database Systems · Extendible Hashing with Last-Bits Keys, Overflow and Deletion

The idea in one paragraph

Extendible hashing is a dynamic hash file organisation: the file grows and shrinks one bucket at a time, and no full reorganisation is ever needed. A directory (an array of pointers) is indexed by the last ii bits of the hash value of a key. Each directory entry points to a bucket. When a bucket overflows, we split it (doubling the directory if needed, and repeating if all its keys fall on the same side); only when more than bb records have the same complete hash value (e.g. duplicates) do we attach an overflow bucket. Deletion reverses this: merge buddies, then halve the directory.


Notation and the two conventions

SymbolMeaning
KKthe key (a decimal integer in GATE questions)
h(K)h(K)hash value; here h(K)=K mod 2ih(K)=K \bmod 2^i
iiglobal depth — number of low-order (last) bits of h(K)h(K) used by the directory
iji_jlocal depth of bucket jj — number of low-order bits on which all keys in bucket jj agree
bbbucket capacity (number of records per bucket)
ddnumber of directory entries =2i=2^i

Convention warning (state this in the exam):

  • Many GATE questions (and Ramakrishnan–Gehrke) use global depth ii, local depth iji_j and the last (least significant) ii bits, h(K)=K mod 2ih(K)=K \bmod 2^i. This chapter uses that convention.
  • Silberschatz–Korth–Sudarshan index the directory by the first (high-order) bits of the hash value and write ii for the global depth and iji_j for a bucket's depth.
  • Some texts use the first (most significant) bits; the mechanics are identical, only the bit position changes. If the question says "last ii bits" or gives h(K)=K mod 2ih(K)=K \bmod 2^i, use LSB-first. If it says "first ii bits", take the leading bits of the binary form.

Key facts to memorise:

  • Directory size d=2id = 2^{i}.
  • A bucket with local depth iji_j is pointed to by exactly 2 i−ij2^{\,i-i_j} directory entries (its buddy group).
  • ij≤ii_j \le i always.
  • Two buckets are buddies if they have the same local depth iji_j and their hash suffixes differ only in the (ij)(i_j)-th bit (i.e. they agree on the last ij−1i_j-1 bits).

Pages 1–2 of 2