Question: What does the following program do? Whats its time complexity? Justify. int myFun(A[0..N-1], value, low, high) { if (high < low) return -1; mid =

What does the following program do? Whats its time complexity? Justify.

int myFun(A[0..N-1], value, low, high) { if (high < low) return -1; mid = low + ((high - low) / 2); if (A[mid] > value) return myFun(A, value, low, mid-1); else if (A[mid] < value) return myFun(A, value, mid+1, high); else return mid; }

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!