If the key is the first element, how many comparisons does linear search make?
A2
B4
C9
D1
Answer & Solution
Correct answer: D. 1
1. Linear search starts at the beginning of the list.
2. A match there ends the search at once.
3. If the key is the first element, linear search always makes only 1 comparison.
4. So the answer is 1.
_Source: syllabus Computer Science, Ch 5 'Sorting' and Ch 6 'Searching'_
Keep practising Sorting and Searching
Browse all Sorting and Searching questions for IGNOU MCA, or explore more Computer Science topics.