• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Searching Algorithm with Answers

Question 21

What is sentinel value in Sentinel Linear Search?

  • The middle element

  • The second element

  • The last element

  • None

Question 22

What is the time complexity for performing Jump search?

  • O(LogN)

  • O(N)

  • O(N^2)

  • O(√N)

Question 23

How many comparisons are required in the worst case a traditional linear search utilizes?

  • N

  • N + 1

  • 2N

  • N + 2

Question 24

In the worst case, (for instance where the numerical values of the keys increase exponentially) the interpolation search technique will take how many comparisons.?

  • O(N)

  • O(logN)

  • O(loglogN)

  • None

Question 25

Match the following:

List - IList - II
(a) Fibonacci Search(i) O(N)
(b) Jump Search(ii) O(√N)
(c) Sentinel Linear Search(iii) O(log2(log2 n))
(d) Interpolation Search(iv) F(n) = F(n-1) + F(n-2)

Hints:

 (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 26

What are the advantages of Linear Search Over Binary Search?

  • The array is ordered.

  • Less number of comparison

  • less time and space complexity

  • Linear search can be used irrespective of whether the array is sorted or not

Question 27

what is the output of the below code if the input array is [12, 34, 56, 29, 78]. and the X= 21?

C++
int fun(int arr[], int N, int x)
{
	for (int i = 0; i < N; i++)
		if (arr[i] == x)
			return i;
	return -1;
}
  • 0

  • 1

  • -1

  • None

Question 28

What is wrong with the below algorithm for searching the missing number from 1 to n?

int getMissingNo(int a[], int n)
{
	int i, total;
	total = (n + 1) * (n + 2) / 2;
	for (i = 0; i < n; i++)
		total += a[i];
	return total;
}

  • variable 'total' can not be modified.

  • Infinite loop

  • Run time error

  •  we are using Add("+") operation instead of subtraction("-").

There are 28 questions to complete.

Last Updated :
Take a part in the ongoing discussion