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


Merge sort


function sort( var r : list; n : integer ) : list; var temp : list; begin if r = nil then sort := nil else if n>1 then sort := merge( sort( r, n div 2 ), sort( r, (n+1) div 2 )) else begin temp := r; r := r^.next; temp^.next := nil; sort := temp end end;

C source (421.sort.c) Pascal source (421.sort.p)



© Addison-Wesley Publishing Co. Inc.