Question: java: i am having a hard time understanding this concept and if so please follow the below guidelines and explain what you do for me
java: i am having a hard time understanding this concept and if so please follow the below guidelines and explain what you do for me thanks
draw a binary search tree (BST) using these values : 4, 6, 11, 22, 53, 94, 21, 53
then select one of the leaves of the bst you chose and show how the below contains algorithm goes through its execution on the bst to find the node you have selected.
the contains algorithm:
private boolean contains (AnyType x, binaryNode
if (t == null) return false;
in compareResult = x.compareTo (t.element);
if (compareResult < 0){
return contains (x, t.left); }
else if (compareResult > 0){
return contains (x, t.right); }
else {
return true; //math }
}
and then alongside on your bst drawing, trace the path contains method.
thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
