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!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

complexity of algo

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

Comments

  • DrMartenDrMarten 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>>>

    http://www.google.co.uk/search?hl=en&ie=ISO-8859-1&q=bubble+sort&meta=

    Hope this helps. :-)



  • jayaram_bjayaram_b 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]

Sign In or Register to comment.