• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top 50 Algorithms MCQs with Answers

Question 41

The time taken by binary search algorithm to search a key in a sorted array of n elements is

  • O ( log2n )

  • O ( n )

  • O ( n log2n )

  • O ( n^2)

Question 42

Match the following:

List - IList - II
(a) Sequential Search(i) Dynamic programming principle
(b)Branch - and - bound(ii) repeatedly double index
(c) Exponential Search(iii) O(LogN)
(d) Binary Search(iv)O(N)

codes:

 (a)(b)(c)(d)
(1)(i)(iv)(iii)(ii)
(2)(iv)(i)(ii)(iii)
(3)(i)(iv)(ii)(iii)
(4)(iv)(ii)(i)(iii)
  • (1)

  • (2)

  • (3)

  • (4)

Question 43

Number of comparisons required for an unsuccessful search of an element in a sequential search, organized, fixed length, symbol table of length L is
  • L
  • L/2
  • (L+1)/2
  • 2L

Question 44

The necessary condition for using binary search in an array is :-

  • The array should not be too long

  • The array should of more size

  • The array should be sorted 

  • None of these

Question 45

Consider the following C program that attempts to locate an element x in an array Y[] using binary search. The program is erroneous. (GATE CS 2008) 

C
1.   f(int Y[10], int x) {
2.     int i, j, k;
3.     i = 0; j = 9;
4.     do {
5.             k =  (i + j) /2;
6.             if( Y[k] < x)  i = k; else j = k;
7.         } while(Y[k] != x && i < j);
8.     if(Y[k] == x) printf (\"x is in the array \") ;
9.     else printf (\" x is not in the array \") ;
10. }

On which of the following contents of Y and x does the program fail?

  • Y is [1 2 3 4 5 6 7 8 9 10] and x < 10

  • Y is [1 3 5 7 9 11 13 15 17 19] and x < 1

  • Y is [2 2 2 2 2 2 2 2 2 2] and x > 2

  • Y is [2 4 6 8 10 12 14 16 18 20] and 2 < x < 20 and x is even

Question 46

For constants a≥1 and b>1, consider the following recurrence defined on the non-negative integers:
T(n) = a⋅T(n/b) + f(n) 
Which one of the following options is correct about the recurrence T(n)?
  • A
  • B
  • C
  • D

Question 47

For parameters a and b, both of which are ω(1), T(n)=T(n1/a)+1, and T(b)=1. Then T(n) is
  • Θ(logalogbn)
  • Θ(logabn)
  • Θ(logblogan)
  • Θ(log2log2n)

Question 48

We can show that the clique problem is NP-hard by proving that
  • CLIQUE ≤ P 3-CNF_SAT
  • CLIQUE ≤ P VERTEX_COVER
  • CLIQUE ≤ P SUBSET_SUM
  • None of the above

Question 49

Standard planning algorithms assume environment to be __________.
  • Both deterministic and fully observable
  • Neither deterministic nor fully observable
  • Deterministic but not fully observable
  • Not deterministic but fully observable

Question 50

Suppose T(n) = 2T(n/2) + n, T(0) = T(1) = 1 Which one of the following is false. ( GATE CS 2005)
a) T(n) = O(n^2)
b) T(n) = [Tex]\\theta[/Tex](nLogn)
c) T(n) = [Tex]\\Omega[/Tex](n^2)
d) T(n) = O(nLogn)
  • A
  • B
  • C
  • D

There are 50 questions to complete.

Last Updated :
Take a part in the ongoing discussion