Thread: [Help]C++
View Single Post
Old 02-23-2011   #25
Kingroudy
Super Moderator
 
Kingroudy's Avatar
 
Last Online: 02-16-2022
Join Date: May 2006
Posts: 5,580
Thanks: 1,888
Thanked 2,653 Times in 1,593 Posts
Groans: 55
Groaned at 35 Times in 32 Posts
Default

this algorithm is so raggedy ass.
you find out which is the smallest, you put it first.
you find out which is second smallest, you put it second, then, you need to shift (to the left) the elements that are between index 2 to index X-1 inclusive (where X is the original index of the second smallest value). After that, you check for the smallest value between index X+1 and the end of the array, and then put it at index X+1, shifting the elements that have index between X+1 and Y-1 to the left (where Y is the index of the smallest value between X+1 and the end).
and so on.
__________________
click on 'Groan' to switch to my left testicle.
Kingroudy is offline   Reply With Quote