www.delorie.com/gnu/docs/avl/libavl_107.html   search  
 
Buy GNU books!


GNU libavl 2.0.1

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.5.6 Symmetric Case

Here's the code for the symmetric case, where the deleted node was in the right subtree of its parent.

 
y-&#62;avl_balance--;
if (y-&#62;avl_balance == -1)
  break;
else if (y-&#62;avl_balance == -2) 
{ struct avl_node *x = y-&#62;avl_link[0]; if (x-&#62;avl_balance == +1)
{ struct avl_node *w; &#60;@xref{\NODE\, , Rotate left at x.&#62; then right at y in AVL tree,156} pa[k - 1]-&#62;avl_link[da[k - 1]] = w; }
else
{ y-&#62;avl_link[0] = x-&#62;avl_link[1]; x-&#62;avl_link[1] = y; pa[k - 1]-&#62;avl_link[da[k - 1]] = x; if (x-&#62;avl_balance == 0)
{ x-&#62;avl_balance = +1; y-&#62;avl_balance = -1; break; } else
x-&#62;avl_balance = y-&#62;avl_balance = 0; } }
This code is included in @refalso{171


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003