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,

  1. A.

    The number of edges in the longest path from root to leaf in T

  2. B.

    The number of nodes in the longest path from root to leaf in T

  3. C.

    Number of leaves in T

  4. D.

    Total number of nodes in T

Attempted by 425 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…