Question: In java, Write a driver program, test progam or class that I can use to check that the method below works. The original problem was

In java, Write a driver program, test progam or class that I can use to check that the method below works. The original problem was

In java, Write a driver program, test progam or class that I

the method created from the problem is below and that is what I need a driver program/class for. Thank you.

void printBstKeys(Node T, int k1, int k2)

{

if (T == null) return;

if (k1

printBstKeys(T.left, k1, k2);

if (k1 = T.data)

System.out.print(T.data + " ");

if (k2 > T.data)

printBstKeys(T.right, k1, k2);

}

Write a method that takes as input a binary search tree, T, and two keys k1 and k2, which are ordered so that ki s k2, and prints all elements X in the tree such that ki s Key(X) s k2. Do not assume any information about the type of keys except that they can be ordered (consistently). Your program should run in O(K +log N) average time, where K is the number of keys printed. Bound the running time of your algorithm 4.37

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!