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
Correct Answer:
Verified
Q44: Consider the following binary search tree diagram:
Q45: Consider the following addNode method for inserting
Q46: In a binary search tree, where the
Q47: Consider the following binary search tree diagram:
Q48: Consider the following binary search tree diagram:
Q50: In a binary search tree, where the
Q51: A completely filled binary tree with a
Q52: Consider the following tree diagrams:
Q53: If both of the child references of
Q54: Consider the following binary search tree diagram:
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents