CS FundamentalsVery hardGATE CS (PYQ pattern)

A linear hashing file starts with 2 buckets (hash h0 = k mod 2, then h1 = k mod 4, h2 = k mod 8, ...), a bucket holds 2 keys before it overflows, and every insertion that makes a bucket exceed 2 keys (overflow goes to a chain) triggers a split of the bucket at the split pointer (initially bucket 0), after which the pointer advances (and the round restarts when it reaches the end). Keys inserted: 4, 8, 12, 16, 5, 9, 3, 7, 11, 2, 6. How many buckets exist at the end, and where is the split pointer?

  1. A. 5 buckets, split pointer 1
  2. B. 6 buckets, split pointer 1
  3. C. 5 buckets, split pointer 2
  4. D. 4 buckets, split pointer 0

Correct answer: A. 5 buckets, split pointer 1

Simulating each insertion and split gives buckets [[8, 16], [5, 9], [2, 6], [3, 7, 11], [4, 12]] with the pointer at 1 (level 1).

More DBMS and SQL questions

Exams that ask this topic