The asymptotic order of the total number of comparisons in the standard bubble…
2011
The asymptotic order of the total number of comparisons in the standard bubble sort is:
Answer: D. None of the listed classes — ConceptFor an adjacent-comparison sorting process, each completed pass can place one extreme element in its final position, so the remaining unsorted portion…
- A.
O(log n)
- B.
O(n log n)
- C.
O(n)
- D.
None of the listed classes
Attempted by 153 students.
Show answer & explanation
Correct answer: D
Concept
For an adjacent-comparison sorting process, each completed pass can place one extreme element in its final position, so the remaining unsorted portion becomes shorter by one.
When successive passes perform n-1, n-2, ..., 1 comparisons, the total is an arithmetic-series sum; its highest-degree term determines the asymptotic order.
Application
For n elements, the first pass compares n-1 adjacent pairs.
The later passes compare n-2, n-3, ..., 1 pairs because the sorted suffix grows by one element after each pass.
Therefore the total number of comparisons is (n-1)+(n-2)+...+1 = n(n-1)/2.
Expanding the expression gives (n2-n)/2; the n2 term dominates for large n, so the order is O(n2).
Cross-check
For n=5, the passes use 4+3+2+1=10 comparisons, and n(n-1)/2 gives 5×4/2=10. This agreement confirms the counting formula.
Thus the comparison count has order O(n2). The explicit offered growth classes are O(log n), O(n log n), and O(n); none equals O(n2), so the appropriate offered choice is “None of the listed classes.”