Algorithm Analysis questions — page 2 of 2

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

Q20

GATE CS 2015 CS-3Algorithm AnalysisMCQ1 mark−1/3 if wrong
Consider the equality ∑i=0ni3=X\sum_{i=0}^{n} i^3 = X and the following choices for XX

I.Θ(n4)II.Θ(n5)III.O(n5)IV.Ω(n3)\begin{array}{rl} \text{I.} & \Theta(n^4) \\ \text{II.} & \Theta(n^5) \\ \text{III.} & O(n^5) \\ \text{IV.} & \Omega(n^3) \end{array}

The equality above remains correct if XX is replaced by
Show answer without attempting

Answer: C

Q37

GATE CS 2015 CS-3Algorithm AnalysisMCQ2 marks−2/3 if wrong
Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size 64. Which of the following most closely approximates the maximum input size of a problem that can be solved in 6 minutes?
Show answer without attempting

Answer: B

Q64

GATE CS 2015 CS-3Algorithm AnalysisMCQ2 marks−2/3 if wrong
Let f(n)=nf(n) = n and g(n)=n(1+sin⁡n)g(n) = n^{(1+\sin n)}, where nn is a positive integer. Which of the following statements is/are correct?

I.f(n)=O(g(n))II.f(n)=Ω(g(n))\begin{array}{rl} \text{I.} & f(n) = O(g(n)) \\ \text{II.} & f(n) = \Omega(g(n)) \end{array}
Show answer without attempting

Answer: D

Q14

GATE CS 2015 CS-1Algorithm AnalysisMCQ1 mark−1/3 if wrong
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting nn (≥2\geq 2) numbers? In the recurrence equations given in the options below, cc is a constant.
Show answer without attempting

Answer: B

Q60

GATE CS 2015 CS-1Algorithm AnalysisMCQ2 marks−2/3 if wrong
An algorithm performs (log⁡N)1/2(\log N)^{1/2} find operations, NN insert operations, (log⁡N)1/2(\log N)^{1/2} delete operations, and (log⁡N)1/2(\log N)^{1/2} decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?
Show answer without attempting

Answer: A

Q64

GATE CS 2015 CS-1Algorithm AnalysisMCQ2 marks−2/3 if wrong
Consider the following C function.
int fun1(int n) {
    int i, j, k, p, q = 0;
    for (i = 1; i < n; ++i) {
        p = 0;
        for (j = n; j > 1; j = j/2)
            ++p;
        for (k = 1; k < p; k = k*2)
            ++q;
    }
    return q;
}
Which one of the following most closely approximates the return value of the function fun1?
Show answer without attempting

Answer: D

Q16

GATE CS 2015 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
An unordered list contains nn distinct elements. The number of comparisons to find an element in this list that is neither maximum nor minimum is
Show answer without attempting

Answer: D

Q13

GATE CS 2014 CS-2Algorithm AnalysisMCQ1 mark−1/3 if wrong
Which one of the following correctly determines the solution of the recurrence relation with T(1)=1T(1) = 1?

T(n)=2T(n2)+log⁡nT(n) = 2T\left(\frac{n}{2}\right) + \log n
Show answer without attempting

Answer: A

Q31

GATE CS 2013 CSAlgorithm AnalysisMCQ2 marks−2/3 if wrong
Consider the following function:
int unknown(int n){
  int i, j, k=0;
  for (i=n/2; i<=n; i++)
    for (j=2; j<=n; j=j*2)
      k = k + n/2;
  return (k);
}
The return value of the function is
Show answer without attempting

Answer: B

Q18

GATE CS 2012 CSAlgorithm AnalysisMCQ1 mark−1/3 if wrong
Let W(n)W(n) and A(n)A(n) denote respectively, the worst case and average case running time of an algorithm executed on an input of size nn. Which of the following is ALWAYS TRUE?
Show answer without attempting

Answer: C

0/110 correct0 marks

Related topics in Algorithms