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 t){

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!