Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!