Multiple choice

Consider the following C program segment where CellNode represents a node in a binary tree:

Struct Cell Node {
  Struct Cell Node * left child;
  Int element;
  Struct Cell Node * right Child;
};
Int Get Value(struct Cell Node * ptr) {
  Int Value = 0;
  if (ptr! = NULL)
    if ((ptr - > left child == NULL) &&
      (ptr - > right Child == NULL))
      Value = 1;
    else
      Value = value + GetValue(ptr - > left Child) + Get Value(ptr - > right child);
}
return (value);
}

The value returned by GetValue when a pointer to the root of a binary tree is passed as its argument is:

  1. the number of nodes in the tree

  2. the number of internal nodes in the tree

  3. the number of leaf nodes in the tree

  4. the height of the tree

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