GATE | CS | 2017 | Set 2 | C Programming | Loops & Conditional | Question 49

Last Updated :
Discuss
Comments

Consider the following C function.

int fun(int n)
{
int i, j;
for (i = 1; i <= n ; i++)
{
for (j = 1; j < n; j += i)
{
printf("%d %d", i, j);
}
}
}

Time complexity of fun in terms of θ notation is:

θ(n √n)

θ(n2)

θ(n log n)

θ(n 2 log n)

Share your thoughts in the comments