adplus-dvertising
frame-decoration

Question

What is the time complexity of following code:
int i, j, k = 0;
for (i = n / 2; i <= n; i++) 
{
for (j = 2; j <= n; j = j * 2) 
{
k = k + n / 2;
}
}

a.

O(n)

b.

O(nLogn)

c.

O(n²)

d.

O(n²Logn)

Answer: (b).O(nLogn)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the time complexity of following code: