Homework 7 - AVL Trees (Extra Credit)

Due: Wednesday June 9, 2010 at 5:00pm
Note: Since this is an extra credit assignment, no late assignments will be accepted. The solution will be posted in the evening of Wednesday June 9th so that you can study them before the final on Friday June 11th.

The purpose of this assignment is to modify BST.h from Lab 6 to implement the AVL tree insertions.

Rename the file AVL.h and rename the class to AVL. In order to properly implement the AVL tree, you will need to implement the left rotation, right rotation, left-right rotation and right-left rotation. Add four new functions for these rotations. Additionally, you will need to add a balance factor variable (or function) to the node class so that insert can detect when a rotation is needed and determine which rotation to perform. Then you will have to modify insert to check the balance factors and perform rotations as needed.

Test your AVL code with hw7main.cpp.