Question: What is the recurrence relation for the given code below? private static void function _ foo ( int [ ] a , int i ,

What is the recurrence relation for the given code below?
private static void function_foo(int [] a, int i, int j)
{
if (i >= j) return;
int mid =(i + j)/2;
int k= rand(); // this is a constant time operation that can be considered as 1.
function_foo (a, i, mid); // inputs the left half of the original array a[]
function_foo (a, mid+1, j); // inputs the right half of the original array a[]
}
a) Tn=2 Tn +2n;
b) Tn = Tn-1+1;
c) Tn =2 Tn/2+1;
d) Tn = n log n +1;
e) Tn=2 T2n + n;

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!