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?

  1. A.

    O(n) and O(1)

  2. B.

    O(n) and O(log n)

  3. C.

    O(n) and O(n)

  4. D.

    O(log n) and O(log n)

Attempted by 182 students.

Show answer & explanation

Correct answer: C

Using linear search : 1️⃣ Unordered list: You may need to check every element in the worst case. ➡ Worst-case time = O(n) 2️⃣ Ordered list: Even though the list is sorted, linear search still checks elements one by one until the key is found or list ends. ➡ Worst-case time = O(n) Thus for unordered and ordered lists respectively: ➡ O(n) and O(n)

Explore the full course: Up Lt Grade Assistant Teacher 2025