Hello everyone, i'm very new to programming and am currently taking my first programming class. I have been assigned a project that asks me to sort an array using a selection sort. I'm not to sure as to where to start this program. I know I have to setup a loop within a loop which will allow the swapping of the integers to occur but other then that I am lost. If someone could help me get started on the program, that would be great.
Here is the project assignment...
Write a c++ function selectSort that will sort an array of n integers in ascending order. Here is a selection sort algorithm that is named this way because for each array position it selects the correct value to place there and swaps it with the value in that position. Below are some hints to setup the program.
1. Repeat for each array position toFill for 0 to n-2.
2. Let smallPos be the subscript of the smallest value in array elements toFill...n-1
- initialize smallPos to toFill
- repeat for pos ranging from toFill to n-1
- if list(pos) is smaller than list(smallPos)
- copy the value of pos into smallPos
3. if smallPos does not equal toFill swap list (smallPos) and list (toFill)
Thank you very much, I had already looked at this site before I wrote this and understood some of it but was still unsure about a few things...I will read it over again and try to understand it all better. Thanks again for the help.