Advertisements
Advertisements
Question
How many comparisons of Linear search will be required to search for key = 17 in the list [8,-4,7,17,0,12,56]?
Options
4
7
8
5
MCQ
Solution
4
Explanation:
List [8, -4, 7, 17, 0, 12, 56] has 7 elements, and the Linear search method compares the key to each member in the list one by one. Because key '17' is at index 3, which is the fourth position in the list, a match would be found in four comparisons. As a result, the answer is 4.
shaalaa.com
Linear Search
Is there an error in this question or solution?