procedure merge ( a,b : RecordArray; var c : RecordArray; na,nb : integer );
{*** Merges the arrays a and b into c (increasing order assumed)
a or b may coincide with c ***}
begin
while (na>=1) or (nb>=1) do
if na<1 then
while nb>0 do begin
c[nb] := b[nb];
nb := nb-1
end {while}
else if nb<1 then
while na>0 do begin
c[na] := a[na];
na := na-1
end {while}
else if a[na].k < b[nb].k then begin
c[na+nb] := b[nb];
nb := nb-1
end {if...then}
else begin
c[na+nb] := a[na];
na := na-1
end; {else}
end;
|