X302: Binary Tree Leaf Nodes Count Exercise

Write a recursive function to count the number of leaf nodes in the binary tree pointed at by "root". Assume there is "isLeaf" method to check if the node is leaf or not. You must use the "isLeaf" method. That is, do not check the value of the left and right children to see if they are null or not to decide if the node is a leaf.

Your Answer:

Reset

Feedback

Your feedback will appear here when you check your answer.