Consider the following C function int fun(int n) { int i, j; for(i=1; i<=n;…

PYQ GATE 2017

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 funfun in terms of Θ\Theta notation is

  1. A.

    Θ(nn)\Theta(n \sqrt{n})

  2. B.

    Θ(n2)\Theta(n^2)

  3. C.

    Θ(n log⁡n)\Theta(n \: \log n)

  4. D.

    Θ(n2log⁡n)\Theta(n^2 \log n)

Attempted by 423 students.

Sign up free to check your answer

Sign up free

Explore the full course: Zero To Hero

Loading lesson…