Question: URGENT PLEASE Q1: Consider an array a[] = { Abdullah, Butaina, George, Inam, Jim, kawther, kavin, Raba, Robin, Roza} . The name George (target) to

URGENT PLEASE

Q1: Consider an array a[] = { Abdullah, Butaina, George, Inam, Jim, kawther, kavin, Raba, Robin, Roza}. The name George (target) to be searched using the binary search algorithm given below. Trace the variables low, high, and mid to complete the task.

low

high

mid

Public int binarySearch(String[] a, String target) {

low=0 ; high=a.length-1

While (low <= high) {

int mid=(low+high)/2;

int com=target.compareTo(a[mid]);

if (com == 0)

return mid;

else if (com < 0)

high=mid-1;

else

low = mid+l;

}

return -1;

}

Q2: Given the function T(n) = n3 + 20n + 5, show that T(n) is O(n3)

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!