Exam-style question
Try this first
A linear search examines the list [14, 6, 21, 9] for the value 21. How many comparisons are made, and at which zero-based index is the value found?.
- A.2 comparisons, index 1
- B.3 comparisons, index 2
- C.3 comparisons, index 3
- D.4 comparisons, index 2
Answer and explanation
Concise answer
3 comparisons, index 2
Why this is correct
The search compares 21 with 14, then 6, then 21. Therefore, three comparisons are made and the value is at zero-based index 2.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
