The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
119 views

asked in Programming by Junior (979 points) | 119 views
0
200 ??
0

@Shaik Masthan it's O(n^2) I think

0
Yeah I too got

O ( n^2 + nlogn)
0

@Magma yes , its 200, please explain

+1
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})$
0
1 doubt : Sir why you have not taken outer i loop with bound loop......Then their complexity should multiply ? only inner to should add.

Please log in or register to answer this question.

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
48,756 questions
52,850 answers
183,548 comments
68,745 users