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 E into this tree, calling addNode on the root of the tree?
A) H only
B) H and D only
C) H, D, and A
D) H, D, and F
Correct Answer:
Verified
Q49: 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
Q55: Consider the following tree diagrams:
Q56: Given the BinaryTree class (partially shown below),
Q57: Consider the following binary search tree diagram:
Q58: Locating an element in a balanced binary
Q59: Adding an element to a balanced binary
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