What is the worst-case scenario for a linear search in an array of 'n' elements?
What is the worst-case scenario for a linear search in an array of 'n' elements?
Solution
✅ Correct Option: 1
Linear search checks elements one by one from the start. The worst case is when the target is the last element, because all elements must be compared, giving a time complexity of .
The same comparisons are needed when the target is not in the array at all.
Option 2: this is the best case, since the search stops after 1 comparison, .
Options 3 and 4: linear search does not use the order of elements, so whether the array is sorted or unsorted does not decide the worst case.
Related questions:
2026: 24 May Shift 1
2025: 27 May Shift 2
2026: 26 May Shift 1