edited by
510 views
1 votes
1 votes

Do they differ or are they same?

they are confusing me/

edited by

1 Answer

Best answer
0 votes
0 votes

yes both the recurrences are same here.

Just to give you an idea about where may be the difference of recurrence relation.Consider two functions A() & B().

A(n) {

if(n<=1) return 1;

else

return ( A(n/2) + A(n/2) + n );

}

Recurrence for Time Complexity :  T(n) = 2*T(n/2) + 1

Recurrence for Value : T(n) = 2*T(n/2) + n

B(n) {

if(n<=1) return 1;

else

return ( 2*A(n/2) + n );

}

Recurrence for Time Complexity :  T(n) = T(n/2) + 1

Recurrence for Value : T(n) = 2*T(n/2) + n

In this A and B both will return the same value so for getting value for some number n,they will result in same but both the functions having different time complexity as you can see we are getting separate recurrence relation for time complexity.

For Function A, we are getting 2*T(n/2) because we are going to call same function 2 time but in function B,we are taking only T(n/2) because we are calling function only one time after getting the value of T(n/2) we are simply multiplying it by 2.

selected by

Related questions

0 votes
0 votes
1 answer
1
shashi111 asked Aug 27, 2017
526 views
Consider the following recurrence.T(n) = T() + What is the value of recurrence?please explain in detail
0 votes
0 votes
1 answer
2
Hardik1997 asked May 20, 2017
364 views
1 :- T(n) = T(n-2) + n22 :- T(n) = 4T(n/3) + nlgn3 :- T(n) = 3T(n/3 - 2) + n/2
2 votes
2 votes
2 answers
3
Regina Phalange asked Mar 4, 2017
3,031 views
What is the value of following recurrence.T(n) = T(n/4) + T(n/2) + cn^2 T(1) = c T(0) = 0Where c is a positive constantA) O(n^3)B) O(n^2)C) O(n^2logn)D) O(nlogn)