Question:

The worst case time complexity of finding an element using linear search is ______.

Show Hint

Remember:
- Linear Search: Best Case = $O(1)$, Worst Case = $O(n)$.
- Binary Search: Best Case = $O(1)$, Worst Case = $O(\log n)$ (requires sorted data).
Updated On: Jun 11, 2026
  • O(log n)
  • O(n)
  • O(n$^2$)
  • O(n log n)
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation


Step 1: Understanding the Question:

The question asks for the worst-case asymptotic time complexity of locating a specific target value in a collection of size $n$ using the Linear Search algorithm.

Step 2: Key Formula or Approach:

- Linear search is a sequential search algorithm that starts at the first element of a list and compares each subsequent element with the target key until a match is found or the end of the list is reached.
- Let $n$ represent the total number of elements in the array or list.

Step 3: Detailed Explanation:

- Let us analyze the best, average, and worst-case scenarios for Linear Search:
- Best Case: The target element is located at the very first index of the list. Here, only 1 comparison is made, yielding a time complexity of $O(1)$.
- Worst Case: The target element is either at the very last index of the list, or it does not exist in the collection at all. In both cases, the algorithm must sequentially compare the target key with every single one of the $n$ elements in the list. This requires $n$ comparisons.
- Since the number of operations in the worst case scales linearly with the input size $n$, the time complexity is expressed asymptotically as $O(n)$.
- Therefore, the worst-case time complexity of linear search is $O(n)$.

Step 4: Final Answer:

The worst-case time complexity of finding an element using linear search is $O(n)$.
Hence, option (B) is the correct choice.
Was this answer helpful?
0
0