Skip to main contentSkip to solution

If a linear search is performed on 10 elements, how many comparisons will be needed in worst case?

Solution

✅ Correct Option: 2

In linear search, each element is compared with the key one by one. The worst case occurs when the key is at the last position or is not in the list at all, so every element is checked once.

For n=10n = 10 elements, the number of comparisons is n=10n = \boxed{10}.


Option 1: this is the best case, where the key is the first element.

Options 3 and 4: off-by-one errors. Each element needs exactly one comparison, so the count is nn, not n−1n - 1 or n+1n + 1.

Keyboard Shortcuts

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