Skip to main contentSkip to solution

The worst case time complexity of finding an element using linear search is ______.

Solution

✅ Correct Option: 2

Linear search checks elements one by one from the start. In the worst case, the element is at the last position or is absent, so all nn elements are compared.

Number of comparisons in the worst case =n= n, so the time complexity is O(n)\boxed{O(n)}.


Option 1: O(log⁡n)O(\log n) is the worst case of binary search, which needs a sorted array.

Options 3 and 4: O(n2)O(n^2) and O(nlog⁡n)O(n \log n) are typical of sorting algorithms (bubble sort, merge sort), not searching a single list once.

Keyboard Shortcuts

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