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


List merging (Pascal version available)


list merge( a, b ) list a, b; { list temp; struct rec aux; temp = &aux; while ( b != NULL ) if ( a == NULL ) { a = b; break; } else if ( b->k > a->k ) { temp = temp->next = a; a = a->next; } else { temp = temp->next = b; b = b->next; }; temp->next = a; return( aux.next ); };

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



© Addison-Wesley Publishing Co. Inc.