edited by
873 views

1 Answer

Best answer
0 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
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.1k
1.1k views
shashi111 asked Aug 27, 2017
1,147 views
Consider the following recurrence.T(n) = T() + What is the value of recurrence?please explain in detail
0 0 votes
1 1 answer
652
652 views
Hardik1997 asked May 20, 2017
652 views
1 :- T(n) = T(n-2) + n22 :- T(n) = 4T(n/3) + nlgn3 :- T(n) = 3T(n/3 - 2) + n/2
3 3 votes
2 answers 2 answers
4.9k
4.9k views
Regina Phalange asked Mar 4, 2017
4,932 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)
4 4 votes
1 answers 1 answer
3.2k
3.2k views
Shyam Singh 1 asked May 9, 2016
3,165 views
What will be time complexity for both recurrences?$$T(n) = \begin{cases}2 \cdot T \left ( \sqrt n \right ) + \log n & \text{if } n 4\\[1em]1 & \text {if } n \leq 4\end{c...