Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Easy Java Question Implement the getSize(), getHeight() and toList() methods in the following BinaryTree class. import java.util.List; public class BinaryTree { private BinaryTree left;

A Easy Java Question

Implement the getSize(), getHeight() and toList() methods in the following BinaryTree class.

import java.util.List;

public class BinaryTree { private BinaryTree left; private BinaryTree right; private T data;

public BinaryTree(T data) { this.data = data; }

public T getData() { return data; }

public void setLeft(BinaryTree left) { this.left = left; }

public void setRight(BinaryTree right) { this.right = right; }

/* @description This method recursively computes the size of the binary tree * @return an integer >= 1 equal to the number of nodes in the binary tree * rooted at this node. */ public int getSize() { int count; while() // WRITE CODE HERE } /* @description This method recursively computes the height of the binary tree * @return an integer >= 0 equal to the height of the binary tree * rooted at this node. */ public int getHeight() {

// WRITE CODE HERE } /* @description This method recursively appends all data stored in this * binary tree using an inorder traversal * @param a List where all items are to be appeded during an inorder * traversal. */ public void toList(List list) {

// WRITE CODE HERE

} }

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

What is a debt service?

Answered: 1 week ago

Question

=+a. Does it flow? (Can anyone read it out loud without stumbling?)

Answered: 1 week ago

Question

=+e. Does it use simple language, not technical jargon?

Answered: 1 week ago