in Algorithms recategorized by
756 views
0 votes
0 votes

in Algorithms recategorized by
756 views

4 Comments

@Magma yes , its 200, please explain

0
0
Outer Loop runs  : log (n) times  =  {1 , 2 , 4 ,8 .....}

for(i = 0 ;i<=n ; i+=2)  =  [0 , 2, 4 , 6 ,8 ....] --- > It  even number times executed therefore  --- > n/2 times executed

for(j=1 ; j<n ; jx=2) ---> runs log n  times

sequence goes like  = $\frac{n}{2} + log (n) + 2 (\frac{n}{2} + log n) + 4 (\frac{n}{2} + logn) ..... log n times$

$\frac{n}{2} (1+2+4+8...logn times)$  + $log n (1+2+4+8...logn times)$

  = $\bigcirc (n^{2} + n logn) = \bigcirc (n^{2})$
1
1
1 doubt : Sir why you have not taken outer i loop with bound loop......Then their complexity should multiply ? only inner to should add.
0
0

Please log in or register to answer this question.

Answer: