The height of a binary tree is the length of the path to the deepest node. An empty tree has a height of 0, a tree with one node has a...
X285: Binary Tree Height Exercise
The height of a binary tree is the length of the path to
the deepest node. An empty tree has a height of 0, a tree with one
node has a height of 1, and so on. Write a recursive
function to find the height of the binary tree pointed at by
root
.
Here are methods that you can use on the BinNode
objects:
interface BinNode {
public int value();
public void setValue(int v);
public BinNode left();
public BinNode right();
public boolean isLeaf();
}
Your Answer:
Feedback
Your feedback will appear here when you check your answer.