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


GNU libavl 2.0.1

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

9.4.3 Symmetric Case

Here is the corresponding code for the case where insertion occurs in the right subtree of y.

 
struct tavl_node *x = y-&#62;tavl_link[1];
if (x-&#62;tavl_balance == +1)
  { 
&#60;@xref{\NODE\, , Rebalance for +.&#62; balance factor in TAVL insertion in right subtree,309}
} else
{
&#60;@xref{\NODE\, , Rebalance for -.&#62; balance factor in TAVL insertion in right subtree,310}
}
This code is included in @refalso{304

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

 
&#60;@xref{\NODE\, , Rotate right at x.&#62; then left at y in AVL tree; avl => tavl,159}
if (w-&#62;tavl_tag[0] == TAVL_THREAD) 
{ y-&#62;tavl_tag[1] = TAVL_THREAD; y-&#62;tavl_link[1] = w; w-&#62;tavl_tag[0] = TAVL_CHILD; } if (w-&#62;tavl_tag[1] == TAVL_THREAD)
{ x-&#62;tavl_tag[0] = TAVL_THREAD; x-&#62;tavl_link[0] = w; w-&#62;tavl_tag[1] = TAVL_CHILD; }
This code is included in @refalso{308


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