Question
Please Help ASAP!!

Transcribed Image Text:Recursive Functions. 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.
1. The number of leaves in the tree.
2. The number of arcs in the tree.
3. The number of nodes in the tree.
4. The height of the tree (i.e. the longest distance from the root to any leaf).
D
B
H
E
A
F
C
G
th
of computes the number of internal nodes of a regular binary tre

Transcribed Image Text: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 internal Nodes(treeType t)
{if leaf(t) {return 0;}
else {return 1+internal Nodes(t.left)+internal Nodes(t.right);}}
Trace of execution:
internal Nodes (A)
= 1 + internalNodes(B) + internalNodes(C)
= 1 + 1 + internal Nodes (D) + internalNodes(E) +
+ 1 + internal Nodes (F) + internalNodes(G)
= 1 + 1 + 0 + internal Nodes(E) +
+1+0+0
= 1 + 1 + 0 + 1 + internalNodes (H) + internalNodes(1)
+1+0+0
= 1+1+0+1+0+0
+1+0+0
= 4.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 steps with 1 images

Knowledge Booster
Similar questions
- DO NOT COPY FROM OTHER WEBSITES Upvote guarenteed for a correct and detailed answer. Thank you!!!arrow_forward444 DO NOT COPY FROM OTHER WEBSITES Upvote guarenteed for a correct and detailed answer. Thank you!!!arrow_forwardFrom DNS lookups to authoritative and root servers, it's everything here.arrow_forward
arrow_back_ios
arrow_forward_ios