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


Height balanced tree right rotation


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

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



© Addison-Wesley Publishing Co. Inc.