int insert( input, n, r, A )
dataarray input, r; int n, *A;
{ extern int m, m2;
int d, i, ia, ib, iup, j;
datarecord tempr;
if( m < n ) return(0);
for( i=0; i1; ) {
if (d<5) d = 1;
else d = (5*d-1)/11;
for ( i=n-1-d; i>=0; i-- ) {
tempr = input[i];
ia = tempr.k % m2;
for ( j=i+d; j ib); j+=d )
input[j-d] = input[j];
input[j-d] = tempr;
}
}
for( i=0; i= iup ) break;
for( j--; j >= i; j-- )
r[hashfunction(A[ia],input[j].k)].k = NOKEY;
}
if( ib >= 9*m )
/* Cannot build optimal hashing table with m and m2 */
return(0);
}
return(1);
}
|