Solved

Consider the Following Binary Search Tree Diagram: Consider the Following

Question 88

Multiple Choice

Consider the following binary search tree diagram: Consider the following binary search tree diagram:   Consider the following addNode method for inserting a newNode into a binary search tree: public void addNode(Node newNode)  { int comp = newnode.data.compareTo(data) ; if (comp < 0)  { if (left == null)  {left = newNode;} else { left.addNode(newNode) ; } } else { if (right == null)  {right = newNode;} else { right.addNode(newNode) ; } } } Which nodes will be visited in order to insert the letter B into this tree, calling addNode on the root of the tree?  A) H, D, and A B) H and D only C) H only D) H, D, and F Consider the following addNode method for inserting a newNode into a binary search tree:
public void addNode(Node newNode)
{
int comp = newnode.data.compareTo(data) ;
if (comp < 0)
{
if (left == null) {left = newNode;}
else { left.addNode(newNode) ; }
}
else
{
if (right == null) {right = newNode;}
else { right.addNode(newNode) ; }
}
}
Which nodes will be visited in order to insert the letter B into this tree, calling addNode on the root of the tree?


A) H, D, and A
B) H and D only
C) H only
D) H, D, and F

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions