Skip to main contentSkip to solution

Which of the following is the worst case time complexity of the linear search algorithm when 'n' is the number of elements in the list?

Solution

✅ Correct Option: 3

Linear search compares the target with each element one by one. In the worst case, the target is the last element or is not in the list at all, so all nn elements are checked. The number of comparisons grows in direct proportion to nn, so the worst case time complexity is O(n)O(n).


Option 1: O(1)O(1) is the best case, where the target is the first element.

Options 2 and 4: these are the costs of sorting algorithms such as merge sort and bubble sort, not of a single pass through the list.

Keyboard Shortcuts

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