Skip to main contentSkip to solution

Consider the following list=[7, 9, 5, 16, 2, 8, -11]. How many comparisons will be required to find element 20 from this list using the linear search algorithm?

Solution

✅ Correct Option: 2

Linear search checks elements one by one from the start. Since 20 is not in the list, every element must be compared before the search can conclude it is absent.

The list has 7 elements, so the number of comparisons is 7\boxed{7}.


Option 1: this would be the best case, where the target is the first element.

Option 4: 10 is not the length of the list; the number of comparisons cannot exceed the number of elements.

In the worst case (element absent or in the last position), linear search makes nn comparisons for nn elements.

Keyboard Shortcuts

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