Question: Please help 1. A regular binary tree is a binary tree whose internal nodes have exactly two subtrees. Write recursive functions to compute the following

Please help Please help 1. A regular binary tree is a binary tree whose

1. A regular binary tree is a binary tree whose internal nodes have exactly two subtrees. Write recursive functions to compute the following attributes of a regular binary tree; show the trace of execution of each function on the following tree. Assume that you have a Boolean function that tells you whether a node is a leaf. a. The number of leaves in the tree. b. The number of ares in the tree. c. The number of nodes in the tree. d. The height of the tree (i.e. the longest distance from the root to any leaf). Hint: below is a function that computes the number of internal nodes of a regular binary tree, and its trace of execution on the sample tree. int internalNodes (treeType t ) \{if leaf (t) \{return 0 ; \} else \{return 1+ internalNodes ( t. left) +internalNodes ( t. rig ht) ; \}) Trace of execution: internalNodes (A) =1 + internalNodes (B)+ internalNodes (C) =1+1+ internalNodes (D)+ internalNodes (E) + +1+ internalNodes (F)+ internalNodes (G) =1+1+0+ internalNodes (E)+ +1+0+0 =1+1+0+1+ internalNodes (H)+ internalNodes (I) +1+0+0 =1+1+0+1+0+0 +1+0+0 =4

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!