Open In App

Top | MCQs on Searching Algorithm with Answers | Question 25

Last Updated : 24 Jul, 2023
Like Article

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




N + 1




N + 2

Answer: (D)


In Sentinel search, the last element of the array is replaced with the element to be searched and then the linear search is performed on the array without checking whether the current index is inside the index range of the array or not because the element to be searched will definitely be found inside the array even if it was not present in the original array. So, the index to be checked will never be out of the bounds of the array. The number of comparisons in the worst case there will be (N + 2).

Hence Option (D) is the correct answer.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads