Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
06-20-2009, 10:45 AM #1
- Join Date
- Jun 2009
- 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.
06-20-2009, 10:57 AM #2
- Join Date
- Mar 2002
- 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?