Multiple choice

The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree pointer root. int height (treeptr n) The appropriate expressions for the two boxes B1 and B2 are

  1. B1: (1 + height (n$\rightarrow$right)) B2: (1 - max (h1, h2))
  2. B1: (height (n$\rightarrow$right)) B2: (1 - max (h1, h2))
  3. B1: height (n$\rightarrow$right) B2: max (h1, h2)
  4. B1: (1 + height (n$\rightarrow$right)) B2: max (h1, h2)
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation