Subject Computer Science Java Programming


1) Implement a BinaryTree Class based on the content and code of your textbook. This class should have code for data filed, constructors and methods.
2) You should have a class BinaryTreeTest with a main method to test your implementation by calling all implemented methods.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

class Node<E>{

       protected E data;
       protected Node<E> left;
       protected Node<E> right;

       public Node(E data) {
   = data;
            this.left = null;
            this.right = null;

       public String toString() {
            return data.toString();

public class BinaryTree<E>{

    protected Node<E> root;

    public BinaryTree() {
       root = null;

    protected BinaryTree(Node<E> root) {
       this.root = root;

    public BinaryTree(E data, BinaryTree<E> leftTree, BinaryTree<E> rightTree) {
       root = new Node<>(data);
       if (leftTree != null) {
            root.left = leftTree.root;
       } else {
            root.left = null;
       if (rightTree != null) {
            root.right = rightTree.root;
       } else {
            root.right = null;

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor
Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats