in Algorithms retagged by
3,270 views
4 votes
4 votes

Which of the following represents most appropriate asymptotic solution for given reccurance:

(A) O(n)

(B) O(log n)

(C) O(log log n)

(D) O(log n)2

in Algorithms retagged by
3.3k views

3 Comments

O(logn)
0
0
Please provide solution because I'm weak in this type of problem
0
0
take n=2^m

then, it become  T(2^m)= T(2^m/2)+m;

                          write it as S(m)=S(m/2)+m;

                        then apply master's theorem

                        b will be answer
0
0

1 Answer

0 votes
0 votes

T(n) = T( √n) + log2 n   _____________    Eqn 1

Let's take n = 2m , taking log both side.

log2 n = m log22 put in Eqn 1.

T(2m) = T(2m/2) + log2 2m _____________ Eqn 2   

[ ∵ logb bn = n ] using this we can rewrite Eqn 2 as :

T(2m) = T(2m/2) + m

or

S(m) = S(m/2) +m

solve using MT we get, S(m) = O(m)

change the value of m to log2n.

so TC is log2n

Related questions