adplus-dvertising
frame-decoration

Question

What is the time complexity of following code:
int a = 0;
for (i = 0; i < N; i++) 
{
for (j = N; j > i; j--) 
{
a = a + i + j;
}
}

a.

O(N)

b.

O(N*log(N))

c.

O(N * Sqrt(N))

d.

O(N*N)

Answer: (d).O(N*N)

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: