519 views

2 Answers

0 votes
0 votes

Asymptotic Answers ..
a. T(n) = T(n − 3) + 5n − 9
    T(n) = T(n − 3) + O(n)
    Level Cost = O(n), Number of Level = n/3 = O(n)
    T(n) =  Number of Level *  Level Cost = O(n) * O(n) = O(n2)

b.  
T(n)=2T(n − 1) + n- 2n + 1  
     T(n)=2T(n − 1) + O(n2)
     each time two function call, Number of Level = n
     T(n) = O(2n)

0 votes
0 votes

T(n) =T(n-3)+5n- 9

T(n)=T(n-3)+O(n)

Now use T(n)=aT(n-b)+O(n^k)

Condition if a=1 then T(n)=O(n^(k+1))

So and is O(n^2)

2- for second use conditiontion

If a>1 then T(n)=O{n^k a^(n/b)}

Related questions

0 votes
0 votes
0 answers
2