What is the worst-case time complexity of search operation on unordered and…
2022
What is the worst-case time complexity of search operation on unordered and ordered list using linear search algorithm respectively?
- A.
O(n) and O(1)
- B.
O(n) and O(log n)
- C.
O(n) and O(n)
- D.
O(log n) and O(log n)
Attempted by 811 students.
Show answer & explanation
Correct answer: C
Linear search always scans elements one-by-one. Unordered list → worst case O(n)
Ordered list → still worst case O(n) because the target may be at the end or absent.
✔ Answer = O(n), O(n)