GNU libavl 2.0.1
Author: Ben Pfaff

8.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:

    301. <TAVL item insertion function 301> =
    void **
    tavl_probe (struct tavl_table *tree, void *item)
    {
      <avl_probe() local variables; avl => tavl 147>

      assert (tree != NULL && item != NULL);

      <Step 1: Search TAVL tree for insertion point 302>
      <Step 2: Insert TAVL node 303>
      <Step 3: Update balance factors after AVL insertion; avl => tavl 150>
      <Step 4: Rebalance after TAVL insertion 304>
    }

This code is included in 300.

Subsections:

- 8.4.1 Steps 1 and 2: Search and Insert
- 8.4.2 Step 4: Rebalance
- 8.4.3 Symmetric Case

8.3 Operations | 8 Threaded AVL Trees | 8.4.1 Steps 1 and 2: Search and Insert