What is the running time of Bubble Sort when the input is an array where all record values are equal?
\Theta(n^2)
\Theta(n)
\Theta(\log n)
\Theta(n \log n)
Each comparison test in the inner for loop will fail
because the value at position i
is never less
than the value at position i-1
.
However, this observation does not affect the number of comparisons to be made, it only affects the number of swaps