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??

himanjim 0 Junior Poster in Training

sj87 19 Light Poster

StuXYZ commented: Neatly explined. +1

SRaj 0 Newbie Poster

ArkM 1,090 Postaholic

Freaky_Chris 299 Master Poster

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.