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 of the following trees represents the correct result after inserting element B, calling addNode on the root of the tree?
A) III
B) IV
C) II
D) I
Correct Answer:
Verified
Q39: Consider the following tree diagrams:
Q40: A completely filled binary tree with a
Q41: Consider the following binary search tree diagram:
Q42: Which of the following statements about a
Q43: If the child references of a binary
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:
Q49: 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