# Selection Sort

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 09-18-2003
Drew
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?
• 09-18-2003
bennyandthejets
Is there any code associated with your post?
• 09-18-2003
Drew
No code
I am just trying to figure out how the sort works
• 09-18-2003
bennyandthejets
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.
• 09-18-2003
Drew
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
• 09-18-2003
bennyandthejets
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.
• 09-18-2003
Drew
No
No
• 09-18-2003
bennyandthejets
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?
• 09-18-2003
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?
• 09-18-2003
FillYourBrain
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
• 09-18-2003
bennyandthejets
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.
• 09-18-2003
FillYourBrain
Quote:

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.
• 09-18-2003
FillYourBrain
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.
• 09-18-2003
bennyandthejets
Could you explain further the swapping method? I still don't see how consecutive swapping could get us these results.
• 09-18-2003
bennyandthejets
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.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last