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


Height balanced tree left rotation


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;

C source (3413.lrot.c) Pascal source (3413.lrot.p)



© Addison-Wesley Publishing Co. Inc.