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


GNU libavl 2.0.1

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

9.5.5 Symmetric Case

Here's the code for the symmetric case.

 
dir = q-&#62;tavl_link[0] != y;
y-&#62;tavl_balance--;
if (y-&#62;tavl_balance == -1) 
break; else if (y-&#62;tavl_balance == -2)
{ struct tavl_node *x = y-&#62;tavl_link[0]; assert (x != NULL); if (x-&#62;tavl_balance == +1)
{ &#60;@xref{\NODE\, , Rebalance for +.&#62; balance factor after TAVL deletion in right subtree,324} }
else
{ q-&#62;tavl_link[dir] = x; if (x-&#62;tavl_balance == 0)
{ &#60;@xref{\NODE\, , Rebalance for 0 balance factor after TAVL deletion in right subtree.&#62;,325} break; }
else /* x-&#62;tavl_balance == -1 */
{ &#60;@xref{\NODE\, , Rebalance for -.&#62; balance factor after TAVL deletion in right subtree,326} } } }
This code is included in @refalso{318

 
struct tavl_node *w;
&#60;@xref{\NODE\, , Rebalance for +.&#62; balance factor in TAVL insertion in left subtree,307}
q-&#62;tavl_link[dir] = w;
This code is included in @refalso{323

 
y-&#62;tavl_link[0] = x-&#62;tavl_link[1];
x-&#62;tavl_link[1] = y;
x-&#62;tavl_balance = +1;
y-&#62;tavl_balance = -1;
This code is included in @refalso{323

 
if (x-&#62;tavl_tag[1] == TAVL_CHILD)
  y-&#62;tavl_link[0] = x-&#62;tavl_link[1];
else 
{ y-&#62;tavl_tag[0] = TAVL_THREAD; x-&#62;tavl_tag[1] = TAVL_CHILD; } x-&#62;tavl_link[1] = y; y-&#62;tavl_balance = x-&#62;tavl_balance = 0;
This code is included in @refalso{323


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