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


Merging of arrays (Pascal version available)


merge( a, b, na, nb ) RecordArray a, b; int na, nb; { /*** Merge array b (0...nb-1) into array a (0...na-1) ***/ while ( nb > 0 ) if ( na<=0 || a[na-1].k < b[nb-1].k ) { nb--; a[na+nb] = b[nb]; } else { na--; a[na+nb] = a[na]; } };

C source (432.merge.c) Pascal source (432.merge.p)



© Addison-Wesley Publishing Co. Inc.