|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
AVL tree node with balance factor. More...
#include <tpl_binNodeUtils.H>Go to the source code of this file.
Classes | |
| class | AvlNode_Data |
| Data portion of an AVL tree node. More... | |
| class | AvlNode< Key > |
| Declare AvlNode type with 40-byte pool allocation. More... | |
| class | AvlNodeVtl< Key > |
Macros | |
| #define | DIFF(p) ((p)->getDiff()) |
| Access the balance factor of node p. | |
Functions | |
| template<class Node > | |
| bool | is_avl (Node *p) |
| Validate that a tree satisfies AVL properties. | |
AVL tree node with balance factor.
This file defines the AvlNode structure for AVL trees, including the balance factor (height difference) attribute and validation functions.
An AVL tree maintains the invariant that for every node: |height(left) - height(right)| ≤ 1
The balance factor (diff) stores: height(right) - height(left) Valid values are -1, 0, or +1.
| diff | Meaning |
|---|---|
| -1 | Left subtree is 1 taller |
| 0 | Both subtrees have equal height |
| +1 | Right subtree is 1 taller |
Definition in file avlNode.H.
| #define DIFF | ( | p | ) | ((p)->getDiff()) |
Validate that a tree satisfies AVL properties.
Checks that:
| Node | AVL node type |
| p | Root of subtree to validate |
Definition at line 123 of file avlNode.H.
References Aleph::computeHeightRec(), Aleph::diff(), DIFF, is_avl(), Aleph::LLINK(), Aleph::maps(), and Aleph::RLINK().
Referenced by is_avl(), TEST(), and Aleph::Gen_Avl_Tree< NodeType, Key, Compare >::verify().