Given a list:
L = [8, -4, 7, 17, 0, 2, 19]
Find the number of comparisons to locate value 7 in the list using Linear Search.
Given a list:
L = [8, -4, 7, 17, 0, 2, 19]
Find the number of comparisons to locate value 7 in the list using Linear Search.
Solution
✅ Correct Option: 3
Linear search checks the elements one by one from the start of the list, and stops as soon as the value is found.
| Comparison | Element checked | Equal to 7? |
|---|---|---|
| 1 | 8 | No |
| 2 | -4 | No |
| 3 | 7 | Yes |
7 is at index 2, so the number of comparisons is index + 1 = .
Option 2: this counts the index (2) instead of the number of elements checked; the match itself also takes a comparison.
Related questions:
2026: 13 May Shift 2
2025: 14 May Shift 1
2025: 16 May Shift 1
2026: 24 May Shift 1