Treat the live array segment as a FIFO queue of runs. Remove its first two runs, append their merged result, and repeat:Compute both run boundaries before writing the destination, which starts at the old
PROCEDURE Sort(a, b: INTEGER; VAR c, d: INTEGER);
VAR x, y, z: INTEGER;
BEGIN
c := a; d := b;
WHILE c < d DO
x := Run(c, d);
IF x = d THEN RETURN END;
y := Run(x, d);
z := y-c;
Merge(c, x, y, d);
c := y;
d := d+z
END
END Sort;d. The untouched suffix is followed by the new merged run. The endpoints returned in c,d always describe the live sequence; obsolete values before c are ignored. As allowed, assume enough destination capacity. Articles by others on the same topic
There are currently no matching articles.