Question: Convert this java method to do ternary searches instead of binary searches... public static int binarySearch ( Vector A , int n , int T

Convert this java method to do ternary searches instead of binary searches...
public static int binarySearch(Vector A, int n, int T){
int L =0;
int R = n -1;
while (L <= R){
int m =(L + R)/2;
if (A.get(m)< T){
L = m +1;
} else if (A.get(m)> T){
R = m -1;
} else {
//return the index of the given element
return m;
}
}
return -1;
}

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!