Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the BinarySearchTree class. The BinarySearchTree class extends the BinaryTree class which implements the Tree interface. All can be found below. Your assignment is to

Implement the BinarySearchTree class. The BinarySearchTree class extends the BinaryTree class which implements the Tree interface. All can be found below. Your assignment is to implement all of the abstract methods of the BinaryTree class recursively.

They are:

  • Insert.
  • Iterator (non-recursive).
  • Remove.
  • Search.

You must also implement an Iterator inner class for the BinarySearchTree class. You must submit a modified BinarySearchTree.java file with your source code.

Do not submit and do not modify the Tree.java or BinaryTree.java files.

/* * * Tree.java * */ public interface Tree extends Iterable { void insert(E data); void remove(E key); boolean search(E key); } /* * * BinaryTree.java * */ public abstract class BinaryTree implements Tree { protected class Node { protected Node(T data) { this.data = data; } protected T data; protected Node left; protected Node right; } protected Node root; } /* * * BinarySearchTree.java * */ import java.util.Iterator; public class BinarySearchTree> extends BinaryTree { public void insert(E data) { return; } public Iterator iterator() { return null; } public void remove(E key) { return; } public boolean search(E key) { return false; } } 

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Programming questions