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 find(T item);

public ITree insert(T item);

}

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 implements ITree

{ // ...

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> extends Tree> { // ... }

Part 3 Traversal

he goal is to implement the following interface in your BinaryTree class:

import java.util.*;

public interface ITraversable {

public ArrayList nlr(); // Pre-order

public ArrayList lnr(); // In-order

public ArrayList lrn(); // Post-order

public ArrayList bfs(); // Breadth-first }

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 rotateLeft();

public ITree rotateRight();

}

PART 6: AVL trees

public class AVLTree> extends BinaryTree {

private int balance;

private AVLTree parent;

public AVLTree(T item) {

this(item, null);

}

public AVLTree(T item, AVLTree parent) {

super(item);

this.balance = 0;

this.parent = parent; }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!