Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE the iterator and Treeheight recursively Public interface Tree> extends Iterable { int treeheight(); int nodedepth(); } public class BinaryTre> implements Tree { private TreeNode

WRITE the iterator and Treeheight recursively

Public interface Tree> extends Iterable

{

int treeheight();

int nodedepth();

}

public class BinaryTre> implements Tree {

private TreeNode root;

private int size;

@Override

public int size() {

return size;

}

@Override

public boolean isEmpty() {

return size == 0;

}

@Override

public int treeheight() {

return 0;

}

@Override

public int treeHeight() {

return 0;

}

@Override

public Iterator iterator() {

return null;

}

private class TreeNode {

private T data;

private TreeNode left;

private TreeNode right;

public TreeNode(T data) {

this.data = data;

}

@Override

public String toString() {

String left = this.left != null ? this.left.data.toString() : "null";

String right = this.right != null ? this.right.data.toString() : "null";

return left + " " + right;-->

}

}

}

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

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

=+a) Find the EV for his actions.

Answered: 1 week ago

Question

What are the different techniques used in decision making?

Answered: 1 week ago