11-3 Quadratic probing

Suppose that we are given a key kk to search for in a hash table with positions 0,1,,m10, 1, \ldots, m - 1, and suppose that we have a hash function hh mapping the key space into the set {0,1,,m1}\{0, 1, \ldots, m - 1\}. The search scheme is as follows:

  1. Compute the value j=h(k)j = h(k), and set i=0i = 0.
  2. Probe in position jj for the desired key kk. If you find it, or if this position is empty, terminate the search.
  3. Set i=i+1i = i + 1. If ii now equals mm, the table is full, so terminate the search. Otherwise, set j=(i+j)mod  mj = (i + j) \mod m, and return to step 2.

Assume that mm is a power of 22.

a. Show that this scheme is an instance of the general "quadratic probing" scheme by exhibiting the appropriate constants c1c_1 and c2c_2 for equation (11.5)\text{(11.5)}.

b. Prove that this algorithm examines every table position in the worst case.

(Removed)