• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Algorithms in DSA with Answers

Question 41

The infix expression A + (B - C)* D is correctly represented in prefix notation as
  • A + B − C ∗ D
  • + A ∗ − B C D
  • A B C − D ∗ +
  • A + B C − D ∗

Question 42

Consider the following table
       Algorithms                   Design Paradigms
(P) Dijkastra’s Algorithm              (i) Divide and Conquer
(Q) Strassen’s Matrix Multiplication   (ii) Greedy
(R) Fibonacci numbers                  (iii) Dynamic Programming 

Match the algorithm to design paradigms they are based on:
  • P-(ii), Q-(iii), R-(i)
  • P-(iii), Q-(i), R-(ii)
  • P-(ii), Q-(i), R-(iii)
  • P-(i), Q-(ii), R-(iii)

Question 43

The following function computes XY for positive integers X and Y. C
int exp(int X, int Y)
{
    int res = 1, a = X, b = Y;
    while ( b != 0 )
    {
        if ( b%2 == 0)
        {
            a = a*a;
            b = b/2;
        }
        else
        {
            res = res*a;
            b = b-1;
        }
    }
    return res;
}
Which one of the following conditions is TRUE before every iteration of the loop options1
  • A
  • B
  • C
  • D

Question 44

Consider the following pseudo code, where x and y are positive integers.
begin
   q := 0
   r := x
while r >= y do
   begin
      r := r – y
      q := q + 1
   end
end 
The post condition that needs to be satisfied after the program terminates is
  • {r = qx + y ∧ r < y}
  • {x = qy + r ∧ r < y}
  • {y = qx + r ∧ 0 < r < y}
  • { q + 1 < r–y ∧ y > 0}

Question 45

Given an array that represents elements of arithmetic progression in order. It is also given that one element is missing in the progression, the worst case time complexity to find the missing element efficiently is:
  • Θ(n)
  • Θ(nLogn)
  • Θ(Logn)
  • Θ(1)

Question 46

The cube root of a natural number n is defined as the largest natural number m such that m3 ≤ n. The complexity of computing the cube root of n (n is represented in binary notation) is:
  • O(n) but not O(n0.5)
  • O(n0.5) but not O((log n)k) for any constant k > 0
  • O((log n)k) for some constant k > 0, but not O ((log log n)m) for any constant m > 0
  • O((log log n)m) for some constant k > 0.5, but not O((log log n)0.5)

Question 47

The minimum number of arithmetic operations required to evaluate the polynomial P(X) = X5 + 4X3 + 6X + 5 for a given value of X using only one temporary variable.
  • 6
  • 7
  • 8
  • 9

Question 48

The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is 

  • θ(n)

  • θ(logn)

  • θ(nlogn)

  • θ(1)

Question 49

In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is: 

  • nk

  • (n – 1) k+ 1

  • n( k – 1) + 1

  • n( k – 1)

There are 49 questions to complete.

Last Updated :
Take a part in the ongoing discussion