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) Algorithms ace-booklet algorithms time-complexity + – gate_dreams asked Jan 27, 2019 retagged Jun 24, 2022 by Lakshman Bhaiya gate_dreams 353 views answer comment Share Follow See 1 comment See all 1 1 comment reply Verma Ashish commented Jan 28, 2019 reply Follow Share $j=n+\frac{n}{2} +\frac{n}{4}+\frac{n}{8} +\ldots$ Decreasing GP $1+1/2+1/4+1/8+1/16+\ldots =O(1)$ So $val(j)=\theta (n)$ 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes n/2^k=1 n=2^k k=log2n ans is A gorya506 answered Aug 17, 2019 gorya506 comment Share Follow See all 0 reply Please log in or register to add a comment.