Data Structures and Algorithms with Object-Oriented Design Patterns in C#
next up previous contents index

Constructor

A no-arg constructor is shown in Program gif. This constructor creates an empty AVL tree. The height field is set to the value -1, which is consistent with the empty tree. Notice that according to Definition gif, the empty tree is AVL balanced. Therefore, the result is a valid AVL tree. Clearly, the running time of the constructor is O(1).

   program19324
Program: AVLTree class constructor, AdjustHeight method, Height and BalanceFactor properties.


next up previous contents index

Bruno Copyright © 2001 by Bruno R. Preiss, P.Eng. All rights reserved.