Quadratic hashing: search


function search( key : typekey; var r : dataarray ) : integer; var i, inc : integer; begin i := hashfunction( key ) ; inc := 0; while (inc<m) and (not empty(r[i])) and (r[i].k<>key) do begin i := (i+inc+1) mod m; inc := inc + 2 end; if r[i].k=key then search := i {*** found(r[i]) ***} else search := -1; {*** notfound(key) ***} end;

Pascal source (336.srch.p)



© Addison-Wesley Publishing Co. Inc.