What is the best case runtime of linear search(recursive) algorithm on an…

2024

What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?

  1. A.

    O(1)

  2. B.

    O(n)

  3. C.

    O(logn)

  4. D.

    O(nx)

Attempted by 176 students.

Show answer & explanation

Correct answer: A

The best case runtime of linear search occurs when the target element is found at the first position of the array.

In this scenario, only one comparison is needed, resulting in constant time complexity.

Therefore, the best case runtime is O(1).

Explore the full course: Coding For Placement