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


GNU libavl 2.0.1

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

9.4 Insertion

Insertion into an AVL tree is not complicated much by the need to update threads. The outline is the same as before, and the code for step 3 and the local variable declarations can be reused entirely:

 
void **
tavl_probe (struct tavl_table *tree, void *item)
{ &#60;@xref{\NODE\, , avl_probe.&#62;() local variables; avl => tavl,147} assert (tree != NULL && item != NULL); &#60;@xref{\NODE\, , Step 1: Search TAVL tree for insertion point.&#62;,302} &#60;@xref{\NODE\, , Step 2: Insert TAVL node.&#62;,303} &#60;@xref{\NODE\, , Step 3: Update balance factors after AVL insertion; avl =>.&#62; tavl,150} &#60;@xref{\NODE\, , Step 4: Rebalance after TAVL insertion.&#62;,304} }
This code is included in @refalso{300

9.4.1 Steps 1 and 2: Search and Insert  
9.4.2 Step 4: Rebalance  
9.4.3 Symmetric Case  


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