function merge( a, b : tree ) : tree;
begin
if a = nil then merge := b
else if b = nil then merge := a
else if a^.k > b^.k then begin
a^.right := merge( a^.right, b );
fixdist( a );
merge := a
end
else begin
b^.right := merge( a, b^.right );
fixdist( b );
merge := b
end
end;
procedure delete ( var pq : tree );
begin
if pq = nil then Error {*** delete on an empty queue ***}
else pq := merge( pq^.left, pq^.right )
end;
|