GATE CS 2017 (Afternoon) — Question 38

AlgorithmsAsymptotic Analysis (O, Omega, Theta Complexities)MCQ2 marks · −2/3 if wrongMedium

Consider the following C function.
c
1int fun (int n)
2{
3    int i, j;
4    for (i = 1; i <= n; i++)
5    {
6        for (j = 1; j < n; j += i)
7        {
8            printf("%d %d", i, j);
9        }
10    }
11}
12
Time complexity of fun in terms of \(\Theta\) notation is
  1. A
    \(\Theta(n\sqrt{n})\)
  2. B
    \(\Theta(n^2)\)
  3. C
    \(\Theta(n \log n)\)
  4. D
    \(\Theta(n^2 \log n)\)
Practise the full 2017-AN paper
Challenge a friend: WhatsApp Telegram
From RENYXERAThis week's 10-question challengeSame 10 past-GATE questions for everyone this week — see where you stand.
Practise more on Asymptotic Analysis (O, Omega, Theta Complexities)Timed, in the real exam interface · free to start

A GATE question every morning

One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.

Join
Stuck? Ask in the student group