Consider the following function, to which a pointer to the root node of the…
Consider the following function, to which a pointer to the root node of the binary tree T is passed.
int KG(Struct Node *root)
{
int a = 0, b = 0, c = 0;
if(root == NULL) return 0;
if(root -> left == NULL && root -> right == NULL) return 1;
a = KG(root -> left);
b = KG(root -> right);
c = 1 + max(a, b);
return c;
}
The above program computes,
- A.
The number of edges in the longest path from root to leaf in T
- B.
The number of nodes in the longest path from root to leaf in T
- C.
Number of leaves in T
- D.
Total number of nodes in T
Attempted by 425 students.
Sign up free to check your answer
Sign up freeLoading lesson…

