Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Implementing AVL Trees

Having already implemented a binary search tree class, BinarySearchTree, we can make use of much of the existing code to implement an AVL tree class. Program gif introduces the AVLTree class which extends the BinarySearchTree class introduced in Program gif. The AVLTree class inherits most of its functionality from the binary tree class. In particular, it uses the inherited insert and withdraw methods! However, the inherited balance, attachKey and detachKey methods are overridden and a number of new methods are declared.

   program19323
Program: AVLTree class __init__ method.




next up previous index

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