Hi,

I' studying various sorting techniques...And one thing I'm not clear about the complexity of the techniques...

For e.g the complexity of bubble sort is

Average Case=>O(n*n)

Worst Case=>O(n*n)

Best Case=>O(n*n)

Obviously n is the no. of elements in the array...

But even in the worst case i.e the array having 5 elements in descending order would do only only 4+3+2+1 comparisons

and not O(n*n) which I expect is 5*5=25 comparisons

Can somebody please throw light on it??

0