Multiple choice

Consider the following C program segment

The value returned by the function Do Something when a pointer to the proof of a non-empty tree is passed as argument is

  1. the number of leaf nodes in the tree

  2. the number of nodes in the tree

  3. the number of internal nodes in the tree

  4. the height of the tree

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Value initialized by 0 If any root node has left child then it adds 1 to the value & move to left child & if any mode has right child also then also calculated the value using recursion & take maximum of both left & right value is taken. So we know that height is the largest distance between root node & leaf. So this program calculates heights.