Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create an algorithm for the selection sort,

    I need help to create an algorithm for the selection sort, show it as pseudocode OR a flowchart, and desk check with the same two sets of values.

    The outer loop repeats the selection process n-1 times. For each iteration it is initially assumed that the first entry (index 0) contains the highest value (max = 0). The inner loop then examines the array from left to right and whenever a higher value is found, it's locations in the list is stored in the value "max".


    At the end of the first iteration, the last entry in the list has it's value swapped with the entry containing the highest value. The counter of the outer loop is then decremented, so the next highest value will be correctly located, and so on until only the first two are compared and swapped if necessary.

  • #2
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    This looks like a homework assignment. To all respondents, please be very careful not to provide help that goes beyond limiting it to just the problem area of the code. We've had a few suspicious "Homework type" assignments posted on CF lately, with some members basically helping write the entire assignment for him/her. That's helping these individuals cheat.

    When in doubt on how much help goes too far, just put yourself in the shoes of a teacher confronted with a student asking for help on his/her assignment- how much help becomes too much?
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •