GATE 2007 CS – Question 15
For n>0, how many comparisons are made in this loop?
int j,n;
j=1;
while(j<=n) j=j*2;Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) $\lfloor\log_2n\rfloor+1$
Explanation
We are sorry we couldn't write detailed soluition for this, we are working on it!, please consider asking your own AI, its just 2-3 clicks with very minimum effort
More Asymptotic Analysis and Time/Space Complexity questions
- GATE 2007 CS Q44
- GATE 2007 CS Q45
- GATE 2007 CS Q51
- GATE 2026 CS (CS1) Q17
- GATE 2026 CS (CS1) Q47
- GATE 2026 CS (CS2) Q24
All Asymptotic Analysis and Time/Space Complexity questions →