Question
Need a code in java that regards trees. The following les must be present in your submission: Tree.java BinaryTree.java AVLTree.java Part 1 - The Tree
Need a code in java that regards trees.
The following les must be present in your submission:
Tree.java BinaryTree.java AVLTree.java
Part 1 - The Tree Class
The basic interface denition is as follows:
public interface ITree
public T getItem();
public ITree
public ITree
}
This should be included in your project as ITree.java. You must provide an implementation for this interface in form of a Tree class to be dened in Tree.java:
public class Tree
{ // ...
public Tree(T item) {
// ...
}
// ...
}
Part 2 - Binary Search Trees
To do this, we will need to be able to only accept items that are ordinal:
public class BinaryTree
Part 3 Traversal
he goal is to implement the following interface in your BinaryTree class:
import java.util.*;
public interface ITraversable
public ArrayList
public ArrayList
public ArrayList
public ArrayList
Part 4 Measurement
implement another interface:
public interface IMeasurable {
public int size(); public int height();
}
Part 5 Rotation
implement a new interface:
public interface IRotatable
public ITree
public ITree
}
PART 6: AVL trees
public class AVLTree
private int balance;
private AVLTree
public AVLTree(T item) {
this(item, null);
}
public AVLTree(T item, AVLTree
super(item);
this.balance = 0;
this.parent = parent; }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started