0
/ 2.0
Write a recursive function int BTleaf(BinNode root)
to count the number of leaf nodes in the binary tree pointed at by root
. You must use...
Write a recursive function int BTleaf(BinNode root)
to
count the number of leaf nodes in the binary tree pointed at
by root
. You must use the isLeaf()
method in the BinNode
class to check if a node is a leaf.
This is the definition of the BinNode
class:
interface BinNode {
public int value();
public void setValue(int v);
public BinNode left();
public BinNode right();
public boolean isLeaf();
}
Complete the BTleaf
function below.
Your feedback will appear here when you check your answer.