Question:medium

Linear search is useful when:

Show Hint

While binary search has a better time complexity, it requires the data to be sorted. Linear search is the go-to method when the dataset is unsorted or very small.
Updated On: Jun 3, 2026
  • Data is small
  • Data is unsorted
  • Both A and B
  • None
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Understanding the Concept:
In algorithm selection, efficiency is not always about having the lowest mathematical time complexity (\( O \)).
Sometimes, the simplest algorithm is the most practical choice depending on the specific state and size of the input data.
Step 2: Detailed Explanation:
Linear search works by inspecting every element of a list sequentially. Let's analyze why both scenarios provided are correct:
1. Small Data (Option A):
For a very small list (e.g., 5 to 10 elements), the "setup time" or overhead for complex algorithms like binary search is not worth the effort.
Binary search requires the data to be sorted and involves calculating midpoints and performing multiple comparisons.
In contrast, linear search is extremely simple to implement and runs very fast for small inputs because it has almost zero overhead.
On modern processors, a linear scan of a tiny array is often faster in "real time" than a binary search because of how CPU caches work.
2. Unsorted Data (Option B):
This is the most critical use-case for linear search.
More efficient algorithms like binary search only work if the data is already in a specific order (sorted).
If the data is completely unsorted, we cannot make any assumptions about where an element might be.
Therefore, we have no choice but to check every single element one by one to ensure we find the target.
In an unsorted array, linear search is the only straightforward and viable standard option.
To use binary search on unsorted data, you would first have to sort the data (taking \( O(n \log n) \) time).
If you only need to search the list once, performing a linear search (\( O(n) \)) is much more efficient than sorting it just to perform a single search.
Step 3: Final Answer:
Therefore, since linear search is useful for both small datasets and unsorted datasets, option (C) is the correct answer.
Was this answer helpful?
0


Questions Asked in CUET (UG) exam