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


Height balanced tree left rotation (Pascal version available)


tree rrot( t ) tree t; { tree temp; int b; 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, min( -b-t->bal-2, -t->bal-1)); return( t ); }

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



© Addison-Wesley Publishing Co. Inc.