Skip to main contentSkip to solution

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.

ComparisonElement checkedEqual to 7?
18No
2-4No
37Yes

7 is at index 2, so the number of comparisons is index + 1 = 3\boxed{3}.


Option 2: this counts the index (2) instead of the number of elements checked; the match itself also takes a comparison.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question