Q31
Consider the following function:
int unknown(int n){
int i, j, k=0;
for (i=n/2; i<=n; i++)
for (j=2; j<=n; j=j*2)
k = k + n/2;
return (k);
}The return value of the function is
Show answer without attempting
Answer: B
GATE CS · Algorithms · 1 questions
1 Algorithm Analysis question from GATE CS papers (2013), each with the official answer key. Part of Algorithms. Answer any question right here and it is marked straight away, or practise them one at a time.
int unknown(int n){
int i, j, k=0;
for (i=n/2; i<=n; i++)
for (j=2; j<=n; j=j*2)
k = k + n/2;
return (k);
}Answer: B
0/10 correct0 marks