• retagged by
751 views
0 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)

1 Answer

Position:
Show:

Related questions

0 0 votes
2 2 answers
1.1k
1.1k views
Payal Rastogi asked Oct 19, 2016
1,119 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 1 vote
2 answers 2 answers
3.7k
3.7k views
APOORV PANSE asked Jun 1, 2016
3,686 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 1 vote
0 0 answers
1.1k
1.1k views
Ankush Tiwari asked Jul 27, 2016
1,141 views
T(n)=sqrt(2T(n/2))+logn
0 0 votes
1 1 answer
1.5k
1.5k views
JAYKISHAN asked Jul 5, 2018
1,453 views
Given two sorted double linked list L1 and L2 of n elements each, which of the following are true?(A) L1 and L2 can be merged into single sorted list in Θ(n) time.(B) L1 ...