
Advanced Data Structures 461
Based on the above steps, the following algorithm has been developed to compute the height of a
general binary tree:
Algorithm compHeight (Tree)
{
if (Tree == NULL)
{height = 0; return height}
hl = compHeight (leftChild (Tree));
hr = compHeight (rightChild (Tree));
if (hl >= hr) height = hl + 1;
else
height = hr + 1;
return height;
}
The following operations can be performed on an AVL Tree:
(1) Searching an AVL Tree.
(2) Inserting a node in an AVL Tree.
(3) Deleting a node from an AVL Tree.
10.1.1 Searching an AVL Tree
An AVL Tree can be searched for a key K by visiting nodes starting from ...