retagged by
353 views
0 votes
0 votes
for(i=n, j=0; i>0; i/=2, j+=i)

Let val(j) denote the value stored in the variable j after termination of the for loop. Whjch is correct?

a. val(j)=theta(logn)

b. Val(j)= theta(√n)

c. Val(j) = theta(n)

d. Val(j) = theta(nlogn)
retagged by

1 Answer

Related questions

0 votes
0 votes
2 answers
1
Payal Rastogi asked Oct 19, 2016
647 views
I think the median can be found in O(n), because in O(n) we can merge the arrays into a single sorted array and in O(1) we can find the middle element of the array. Am I...
1 votes
1 votes
2 answers
2
APOORV PANSE asked Jun 1, 2016
2,991 views
Consider the following c fragment : void DAA(n) { int i,j,k,x=0; for (i=1 ; i <=n ; i++) for (j=1 ; j <= i * i ; j++) { if ( j mod i == 0 ) for ( k = 1 ; k <= j ; k++) x=...
1 votes
1 votes
0 answers
3
Ankush Tiwari asked Jul 27, 2016
648 views
T(n)=sqrt(2T(n/2))+logn