What does the following function do for a given binary tree? int fun (struct…

 What does the following function do for a given binary tree?

int fun (struct node *root)

{

    if (root == NULL)

       return 0;

    if (root->left == NULL && root->right == NULL)

       return 0;

    return 1 + fun(root->left) + fun(root->right);

}

  1. A.

    Counts leaf nodes

  2. B.

    Counts internal nodes

  3. C.

    Returns height where height is defined as number of edges on the path from root to deepest node

  4. D.

    Return diameter where diameter is number of edges on the longest path between any two nodes.

Attempted by 562 students.

Sign up free to check your answer

Sign up free

Explore the full course: Isro

Loading lesson…