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


Separate chaining hashing: insertion


void insert( key, r ) typekey key; dataarray r; { extern int n; int i; i = hashfunction( key ); if (empty(r[i])) /*** insert in main array ***/ r[i].k = key; else /*** insert in new node ***/ r[i].next = NewNode( key, r[i].next ); n++; }

C source (3311.ins.c)



© Addison-Wesley Publishing Co. Inc.