Algorithm Analysis questions

Q4

GATE CS 2017 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the following functions from positive integers to real numbers:

10,n,n,log⁡2n,100n10, \sqrt{n}, n, \log_2 n, \frac{100}{n}

The CORRECT arrangement of the above functions in increasing order of asymptotic complexity is:
Show answer without attempting

Answer: B

Q3

GATE CS 2017 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
Match the algorithms with their time complexities:
AlgorithmTime complexity
(P) Towers of Hanoi with nn disks(i) Θ(n2)\Theta(n^2)
(Q) Binary search given nn sorted numbers(ii) Θ(nlog⁡n)\Theta(n \log n)
(R) Heap sort given nn numbers at the worst case(iii) Θ(2n)\Theta(2^n)
(S) Addition of two n×nn \times n matrices(iv) Θ(log⁡n)\Theta(\log n)
Show answer without attempting

Answer: C

Q30

GATE CS 2017 CS-2Algorithm AnalysisMCQ2 marks−2/3 if wrong
Consider the recurrence function
T(n)={2T(n)+1,n>22,0<n≤2T(n) = \begin{cases} 2T(\sqrt{n}) + 1, & n > 2 \\ 2, & 0 < n \le 2 \end{cases}
Then T(n)T(n) in terms of Θ\Theta notation is
Show answer without attempting

Answer: B

Q38

GATE CS 2017 CS-2Algorithm AnalysisMCQ2 marks−2/3 if wrong
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 Θ\Theta notation is
Show answer without attempting

Answer: C

0/40 correct0 marks

Related topics in Algorithms