complexity of algo - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# complexity of algo

Posts: 3Member
Hi,
Can anyone tell about concept of complexity. As I am beginner with complexity . Please explain with a sorting algo.
Regards
Omveer

• Posts: 748Member
: Hi,
: Can anyone tell about concept of complexity. As I am beginner with complexity . Please explain with a sorting algo.
: Regards
: Omveer
:

Here goes:->

If you had a long list of random numbers like 34 12 56 7689 693 20 347 2 85 93683 etc or whatever and you wanted to sort them you could do this one of a few ways . In order by value ascending or descending.

As 12 is the lowest number you would have this as the 1st nuber in an ascending list.
93683 would be the highest or 1st number out in a descending list.

If you sorted by string method all the numbers starting with a 1 then a 2 etc would come out regardless of how long the number is.

You would look for the lowest number and the highest number and do a loop between them.

See the following articles on "BUBBLE SORT" routines where the next lowest ( or highest item ) "floats like a bubble through a list" to sort a list out>>>

Hope this helps. :-)

• Posts: 1Member
: Hi,
: Can anyone tell about concept of complexity. As I am beginner with complexity . Please explain with a sorting algo.
: Regards
: Omveer
:
bubble sort algorithm has the order of n^2 where n is the number of numbers.

i.e
for(i=0;i<n;i++)\continues n times
{
for(j=i+1;j<n;j++)\continues n times
{
//compare and swap
}
}

therefore totally n*n times.

hope u would be clear now.

if not forward it here or contact me personally at [email protected]