Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

(a) (-4).

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago

Question

a. What is the purpose of the team?

Answered: 1 week ago