GATE / CS ARCHIVE

GATE CSE 2007 / QUESTION 40

Closed hashing with implicit linear probing

Data Structures · Hashing · Full GATE CSE 2007 paper

GATE 2007, Q40 2 marks · MCQ
Report issue

Hashing

Question 40, GATE 2007: An initially empty hash table has seven slots indexed 0–6 and h(x)=(3x+4) mod 7. Insert 1,3,8,10 in that order using “closed hashing” as stated in the source. Which final table is intended? A dash means an empty slot. The probing rule is not explicitly specified.
Options:
(A) [8,−,−,−,−,−,10]
(B) [1,8,10,−,−,−,3]
(C) [1,−,−,−,−,−,3]
(D) [1,10,8,−,−,−,3]
Tap to enlarge
Your answer
Answer & solution

Answer: B under linear probing (no official key was published)

1. Approach. Under linear probing, collisions advance one slot at a time with wraparound modulo 7. Compute each home position before inserting and never overwrite an occupied slot.

2. Derivation and interpretation. The hash values for 1,3,8,10 are 0,6,0,6. With linear probing, place 1 at 0 and 3 at 6;8 probes from 0 to 1;10 probes 6,0,1 and lands at 2. The table is [1,8,10,empty,empty,empty,3], B. Closed hashing/open addressing does not alone specify the probing sequence; quadratic or double hashing could differ, so linear probing is an explicit assumption rather than a stated guarantee.

Original paper, page 9