Skip to main contentSkip to solution

What happens even if a key is not present in the list during a linear search?

Solution

✅ Correct Option: 4

In a linear search, each element is compared with the key one by one from the start. If the key is not in the list, no comparison ever succeeds, so the algorithm checks every element up to the last one. Only then does it report that the key is not found (for example, by returning -1 or "not found").


Option 1: the algorithm stops midway only when the key is found, not when it is absent.

Option 2: linear search never skips elements. Skipping is a feature of other methods such as jump search.

Option 3: an absent key is a normal outcome and gives a "not found" result, not an error.

Keyboard Shortcuts

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