What is the time complexity of linear search when the element is present at the first position of the list with 'n' elements?
What is the time complexity of linear search when the element is present at the first position of the list with 'n' elements?
Solution
✅ Correct Option: 1
Linear search compares the target with each element from the start. If the element is at the first position, it is found in a single comparison, no matter how large is. The time taken is constant, so the complexity is .
Option 3: is the worst case (element at the last position or absent) and also the average case, not the best case.
Option 2: is the complexity of binary search, which needs a sorted list.
Best case of linear search is , while worst and average cases are .
Related questions:
2026: 20 May Shift 1
2026: 23 May Shift 1
2025: 16 May Shift 1
2026: 31 May Shift 1