Question: Write efficient functions that take only a pointer to the root of a binary search tree, T , and compute: a. The number of nodes

Write efficient functions that take only a pointer to the root of a binary search tree, T, and compute:

a. The number of nodes in T. b. The number of leaves in T. c. The number of full nodes (a full node is a node with two children) in T.

Your main program reads a set of values from DataIn file into the tree, then call the above functions to compute. The main program should print out the answer of each function (a#, b#, c#) as follows, see sample data input / output.

Sample data input: (for a. b. c.): 314596807

Sample data output: a#, b#, c#

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!