AVL Trees

AVLTreeElement<K,E> implements an AVL Tree element in BRIDGES and is inherited from BSTElement<E>.



How does the AVLTreeElement<K,E> work?

AVLTreeElement<K,E> is nearly identical to BSTElement<K,E>, however, it is to be used for building AVL trees, a type of balanced binary search trees (Other examples of balanced search trees include Red-Black Trees, 2-3 Trees). AVL tree inherits all data members and methods of a BSTElement<K,E>, but includes two additional attributes: a balance factor, which represents the difference between the heights of its left and right subtrees, and height, that keeps track of the height of the tree at the node.

An example AVL tree is shown below (and used in the live example further down) with key values and balance factors(in parens):




See also

This tutorial gives an introduction to the usage of AVL trees. You can find the complete documentation of the features in the Doxygen documentation of the following classes and functions:

  1. AVLTreeElement [Java] [C++] [Python]
  2. BSTElement [Java] [C++] [Python]
  3. BinTreeElement [Java] [C++] [Python]
  4. Tree [Java] [C++] [Python]
  5. Element [Java] [C++] [Python]
  6. ElementVisualizer [Java] [C++] [Python]
  7. LinkVisualizer [Java] [C++] [Python]
  8. Color [Java] [C++] [Python]

AVL Tree - BRIDGES Example

Example Details

Java
C++
Python

	    

	    

	    

Bridges Visualization

Well done! You’ve just created an AVL Tree!