[Home]
[Contents]
[Chapter]
[Previous Algorithm]
[Next Algorithm]


Double hashing: search (Pascal version available)


int search( key, r ) typekey key; dataarray r; { int i, inc, last; i = hashfunction( key ) ; inc = increment( key ); last = (i+(n-1)*inc) % m; while ( i!=last && !empty(r[i]) && r[i].k!=key ) i = (i+inc) % m; if (r[i].k==key) return( i ); else return( -1 ); }

C source (335.srch.c) Pascal source (335.srch.p)



© Addison-Wesley Publishing Co. Inc.