Question:

Arrange the following in the ascending order of their time complexity.
(A) Worst Case of Linear Search
(B) Best Case of Binary Search
(C) Worst Case of Binary Search
(D) Worst Case of Bubble Sort
Choose the correct sequence from the options given below:

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

The Correct Option is C

Approach Solution - 1

To arrange the given algorithms by their time complexity, we consider the following complexities for each case:

  • Worst Case of Linear Search: O(n)
  • Best Case of Binary Search: O(1)
  • Worst Case of Binary Search: O(log n)
  • Worst Case of Bubble Sort: O(n^2)

Now, we arrange these complexities in ascending order:

  1. Best Case of Binary Search: O(1)
  2. Worst Case of Linear Search: O(n)
  3. Worst Case of Binary Search: O(log n)
  4. Worst Case of Bubble Sort: O(n^2)

Therefore, the sequence in terms of their time complexities from the smallest to the largest is: (B), (A), (C), (D)

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

Approach Solution -2

The correct ascending order of time complexity is (B), (A), (C), (D).

Additional Context:

  • Time Complexities:
    1. (B) Best Case of Binary Search: O(1) (element at first midpoint)
    2. (A) Worst Case of Linear Search: O(n) (element at end/not present)
    3. (C) Worst Case of Binary Search: O(log n) (element at extremes/not present)
    4. (D) Worst Case of Bubble Sort: O(n²) (reverse sorted array)
  • Key Comparisons:
    • Binary search outperforms linear search in worst case
    • Sorting complexity dominates all search operations
  • Practical Implications:
    • For 1M elements:
      • Binary search: ~20 operations
      • Linear search: ~1M operations

Correct Answer: (3) (B), (A), (C), (D).

Was this answer helpful?
0
0