Consider a list of 10 elements: L=[2, 63, 5, 47, 9, 11, 13, 17, 7, 23].
Determine the number of comparisons to search for a key 13 using linear search.
Consider a list of 10 elements: L=[2, 63, 5, 47, 9, 11, 13, 17, 7, 23].
Determine the number of comparisons to search for a key 13 using linear search.
Solution
✅ Correct Option: 2
Linear search compares the key with each element from the start, one by one, until it finds a match.
| Comparison | Element | Equals 13? |
|---|---|---|
| 1 | 2 | No |
| 2 | 63 | No |
| 3 | 5 | No |
| 4 | 47 | No |
| 5 | 9 | No |
| 6 | 11 | No |
| 7 | 13 | Yes |
So 13 is found at the 7th position, after comparisons.
Option 1: 6 is the index of 13 (counting from 0), not the number of comparisons.
Option 3: linear search does not need a sorted list, so the order does not matter.
Option 4: sorting is needed for binary search, not for linear search.
Related questions:
2026: 24 May Shift 1
2026: 18 May Shift 2
2026: 11 May Shift 2
2026: 29 May Shift 1
2026: 29 May Shift 2