MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Consider this list of numbers:3 4 6 7 8 9. If the number 9 was to be found using a linear search, how many comparisons need to be made?
A
6
B
3
C
8
D
4
Explanation: 

Detailed explanation-1: -The number of comparisons in given context (e.g. comparing criteria at the same level of a branch in a hierarchy, or comparing alternatives against a criterion) can be calculated as n*(n-1)/2, where n is number of items to compare.

Detailed explanation-2: -4 is the correct option. In Linear Search, every element in the list gets checked in each iteration of the loop that is traversing every element of the list.

Detailed explanation-3: -Q. Which of the following is the best description of the linear search algorithm? Put the elements in order, then go through them one by one until target is found or the end of the list is reached.

There is 1 question to complete.