7. Time complexity of bubble sort in best case is
(A) O (n)
(B) 0 (nlogn)
(C) 0 (n2)
(D) 6 (n(logn) 2)
Answers
Answered by
1
Answer:
O(n)
Explanation:
O(n) is the best - case running time for bubble sort. It is possible to modify bubble sort to keep track of the number of swaps it performs. If an array is already in sorted order, and bubble sort makes no swaps, the algorithm can terminate after one pass.
Similar questions