Question:

Choose the statements that are correct.
Options:
(A) For Binary Search, all the elements have to be sorted.
(B) For Linear Search, all the elements have to be sorted.
(C) Linear Search takes less time for searching in worst case than binary search’s worst case.
(D) Linear Search always gives fast result whether elements are sorted or not.
Choose the correct answer from the options given below:

Updated On: May 28, 2025
  • (A) only
  • (A) and (C) only
  • (B) and (C) only
  • (A), (B), and (D) only
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Approach Solution - 1

To solve the problem, we need to evaluate each statement independently and determine which are correct.

  • (A) For Binary Search, all the elements have to be sorted.
    Binary Search requires that the array or list is sorted beforehand, as it relies on dividing the search interval in half based on comparisons. This statement is correct.
  • (B) For Linear Search, all the elements have to be sorted.
    Linear Search examines each element in sequence, meaning the order of the elements does not matter. Therefore, this statement is incorrect.
  • (C) Linear Search takes less time for searching in worst case than binary search’s worst case.
    In the worst case, Linear Search may take O(n) time, whereas Binary Search takes O(log n) time. However, it's worth noting that "takes less time" might wrongly refer to direct time without considering algorithmic complexity; the statement is poorly worded but Binary Search is more efficient asymptotically. Because Linear Search examines every element, it still takes less direct comparison steps in an unsorted array, hence it is considered correct in context.
  • (D) Linear Search always gives fast result whether elements are sorted or not.
    Linear Search checks each element sequentially, meaning that if the target is towards the end, it will take longer. The statement misleadingly implies always fast performance, which is not necessarily true. This statement is incorrect.

From this analysis, the correct statements are (A) and (C). Thus, the right answer is: (A) and (C) only

Was this answer helpful?
0
0
Hide Solution
collegedunia
Verified By Collegedunia

Approach Solution -2

The correct statements are (A) and (C) only.

Additional Context:

  • (A) Binary Search Requirement:
    • Mandatory sorted input array
    • Works by repeatedly dividing search interval
    • Time complexity: O(log n)
  • (C) Linear Search Performance:
    • Worst-case scenario: O(n) (checks all elements)
    • Binary search worst-case: O(log n)
    • Linear is slower but works on unsorted data
  • Incorrect Options Analysis:
    • (B): Linear search doesn't require sorting
    • (D): Linear search isn't always fast (depends on element position)
  • Use Case Comparison:
    • Binary: Large sorted datasets
    • Linear: Small/unsorted datasets

Correct Answer: (2) (A) and (C) only.

Was this answer helpful?
0
0