CS 151 - Introduction to Data Structures

This assignment is optional.
If you do this assignment, it will only count if the grade on this assignment is an improvement on your lowest previous homework. It that case, and in that case only, the grade on this assignment will be used instead of the lowest grade.

Balancing trees (almost)

As discussed in class, and in ch 28 of the text, AVL trees are binary trees that maintain extra information with respect to maintaining balance. In this assignment you will extend the LinkedBinaryTree implementation discussed in class to maintain the AVL information. Importantly, you will not(!!!) be writing code to do the actual rotations, just maintaining the information required to determine if rotation is necessary.

Code is available either from the class website or via scp from goldengate. You will need the following files:

    /home/gtowell/Public/151/A09/StackIntf.java
    /home/gtowell/Public/151/A09/ArrayStack.java
    /home/gtowell/Public/151/A09/LinkedBinaryTree.java 
    /home/gtowell/Public/151/A09/TreeInterface.java 
(You may edit the LinkedBinaryTree code to remove the use of ArrayStack if you want.)

In addition to extending the LinkedBinaryTree code to maintain AVL information you must also adjust the code so that it does not do either insertions or deletions once the tree is out of balance.

Information about the tree to be built is contained in a csv file with the following form:

So, for example if the data file is:
    i,10
    i,5
    i,15
    d,15
    d,12
    i,100
then the resulting tree is
        10
       /   \ 
      5    100
The files will not have poorly formatted data. However, they may include instructions to delete items that are not in the tree. Likewise the data file may include instructions to add or delete items after your code detects an AVL balance problem.

Data files are available via scp from goldengate at

        /home/gtowell/Public/151/A09/d1.csv
        /home/gtowell/Public/151/A09/d2.csv
        /home/gtowell/Public/151/A09/d3.csv
    

Requirements

What to hand in

Electronic Submissions

Your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer.

The following steps for submission assume that you created a project named AssignmentN in the directory /home/YOU/cs151/

  1. For this assignment N=9
  2. Put the README file into the project directory
  3. Go to the directory /home/YOU/cs151
  4. Enter /home/gtowell/bin/submit -c 151 -p N -d AssignmentN

For more on using the submit script click here