procedure lrot( var t : tree );
var temp : tree;
a : integer;
begin
temp := t;
t := t^.right;
temp^.right := t^.left;
t^.left := temp;
{*** adjust balance ***}
a := temp^.bal;
temp^.bal := a - 1 - max( t^.bal, 0 );
t^.bal := min( a-2, a+t^.bal-2, t^.bal-1);
end;
|