I have this method:
static int countLeaves(BinaryNode node) {
if (node == null) {
return 0;
}
else if (node.left == null && node.right == null) {
return 1;
}
return countLeaves(node.left) + countLeaves(node.right);
}
and i want to Write a client program that constructs a binary search tree whose elements are given by the user. Then, find and print the number of leaf nodes in the constructed tree.
I need ur help plz :)