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


Heap insertion (Pascal version available)


insert( new, r ) RecordArray r; ArrayEntry new; {int i, j; extern int n; n++; for (j=n; j>1; j=i) { i = j/2; if ( r[i].k >= new.k ) break; r[j] = r[i]; } r[j] = new; };

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



© Addison-Wesley Publishing Co. Inc.