
Wednesday, May 4, 2016
what is the Complexity of Bubble Sort?

Complexity of Bubble Sort : The time for a sorting algorithm is measured in terms of the number of comparisons. The number f(n) of comparisons in the bubble sort is easily computed.Specially, there are n - 1 comparisons during the first pass, which places the largest element in the last position; there are n - 2 comparisons in the second step, which places the second largest element in the next-to-last position; and so on. Thus
f(n) = (n-1)...