Question: Write a function int countLeaves (Node* node) This function takes a node that is a root of a tree, traverses the tree and returns the

 Write a function int countLeaves (Node* node) This function takes anode that is a root of a tree, traverses the tree andreturns the number of leaves in the tree. The first input in

Write a function int countLeaves (Node* node) This function takes a node that is a root of a tree, traverses the tree and returns the number of leaves in the tree. The first input in test cases is the number of nodes. The second input is nodes of a tree which are inserted into a binary search tree that order. You don't need to implement insert. You have access to the root of the constructed Binary Search Tree. We will create the tree for you, we will call your method to and output the results. The output is the number of leaves in the tree. We have defined the following C++ Node class for you. The name serves as the value class Node ( public: std::string name; Node* left -NULL Node* right - NULL Sample Input 1: 2 01 Sample Output 1

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 Databases Questions!