Multiple Choice
Given the BinaryTree class discussed in section 17.2 (partially shown below) , select an expression to complete the static recursive helper method countLeaves, which returns the number of leaf nodes in the binary tree rooted at node n. public class BinaryTree
{
Private Node root;
Public BinaryTree()
{
Root = null;
}
Public BinaryTree(Object rootData, BinaryTree left, BinaryTree right)
{
Root = new Node() ;
Root.data = rootData;
Root.left = left.root;
Root.right = right.root;
}
Class Node
{
Public Object data;
Public Node left;
Public Node right;
}
Public int countLeaves()
{
Return countLeaves(root) ;
}
Public static int countLeaves (Node n)
{
If (n == null)
{
Return 0;
}
Else if (_____________________)
{
Return 1;
}
Else
{
Return countLeaves(n.left) + countLeaves(n.right) ;
}
}
}
A) n.left == null
B) n.right == null
C) n.left == null && n.right == null
D) n.left == null || n.right == null
Correct Answer:

Verified
Correct Answer:
Verified
Q15: If the child references of a binary
Q16: Consider the following tree diagram: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TB7390/.jpg"
Q17: A binary tree with 260 nodes has
Q18: Given the BinarySearchTree class discussed in section
Q19: Consider the following tree diagram: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TB7390/.jpg"
Q21: Removing an element from an unbalanced binary
Q22: What is the efficiency of adding an
Q23: Consider the following tree diagrams: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TB7390/.jpg"
Q24: Which of the following statements about the
Q25: Consider the following tree diagram: <img src="https://d2lvgg3v3hfg70.cloudfront.net/TB7390/.jpg"