1. ## Selection Sort

If you had this array to do a selection sort G B A H C
the first pass would be ABGHC
the 2nd pass would be ABGHC
the 3rd pass would be ABCHG
the 4th pass would be ABCGH

Why is the first and second pass the same?

2. Is there any code associated with your post?

3. ## No code

I am just trying to figure out how the sort works

4. Okay, then how do you know that each pass will be how you said they would? You must be using something to get that data.

5. ## yes It was in my notes as a example but I do not understand how it is working

yes I do not understand how it is working

6. Do your notes say anything else about selection sorts? Personally, I don't know what they are. Maybe if you explained it to me a little I would understand.

7. ## No

No

8. Could you tell me ANY context information here? What kind of notes does the passage appear in? What is the general topic? How exactly is the data set out?

9. I googled for selection sorting, and I found out the algorithm. The data sequence you showed does not match the selection sort algorithm. Are you sure you copied the data correctly?

10. selection sort is one of the simplest sorts there is. The concept is simply find the min, store it, find the min, store it and so on. Your example doesn't change in a couple steps because the min already lives in the front of the searched area.

GBAHC
A*BGHC
AB*GHC
ABC*HG
ABCG*H

The asterisk represents a divider between the final area and the searched area. If you know what the algorithm is supposed to do, you can see why it doesn't change between a couple steps

11. That's the right algorithm FYB, but the data still doesn't follow it. It SHOULD go like this:

GBAHC
A*GBHC
AB*GHC
ABC*GH
ABCG*H
ABCGH

Drew's data seems to be doing more than just selection sorting.

12. Originally posted by bennyandthejets
I googled for selection sorting, and I found out the algorithm. The data sequence you showed does not match the selection sort algorithm. Are you sure you copied the data correctly?
It does actually. You may have found a linked list version of the algorithm? There is not a need to "swap" in the linked list version.

13. yes, based on your output, bennyandthejets I would say that you've found a linked list version. It's quicker to swap then it is to move the entire array down in the array version.

14. Could you explain further the swapping method? I still don't see how consecutive swapping could get us these results.

15. Okay, I get it now. It's not consecutive, it just swaps the next min value with the first value left in the array. That's pretty ingenious.

Problem solved I guess.