Gate CS-2017-2 Question Paper With Solutions

Q. 49 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:

(A) θ(n √n)

(B) θ(n2)

(C) θ(n log n)

(D) θ(n 2 log n)

Answer: (C)

Explanation:

Gate CS-2017-2 Question Paper With Solutions

Learn More:   Gate EC-2016 - 1 Question Paper With Solutions

LEAVE A REPLY

Please enter your comment!
Please enter your name here