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


Brent's reorganization scheme: insertion (Pascal version available)


void insert( key, r ) typekey key; dataarray r; { extern int n; int i, inc, ii, init, j, jj; init = hashfunction( key ); inc = increment( key ); for (i=0; i<=n; i++) for (j=i; j>=0; j--) { jj = (init + j*inc) % m; ii = (jj + (i-j)*increment(r[jj].k)) % m; if ( empty(r[ii]) || deleted(r[ii]) ) { /*** move record forward ***/ r[ii] = r[jj]; /*** insert new in r[jj] ***/ r[jj].k = key; n++; return; } }; Error /*** table is full ***/; }

C source (3381.ins.c) Pascal source (3381.ins.p)



© Addison-Wesley Publishing Co. Inc.