What is the worst case for linear search?

2024

What is the worst case for linear search?

  1. A.

    O(nlogn)

  2. B.

    O(logn)

  3. C.

    O(n)

  4. D.

    O(1)

Attempted by 1057 students.

Show answer & explanation

Correct answer: C

Answer: c

Explanation: Worst case is when the desired element is at the tail of the array or not present at all, in this case you have to traverse till the end of the array, hence the complexity is O(n).

Explore the full course: Amcat Preparation