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 with AI-Powered 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

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

9781119563099

Students also viewed these Programming questions