Click here to Skip to main content
15,891,777 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945931-Apr-09 17:16
Member 41945931-Apr-09 17:16 
GeneralRe: Stable Quicksort algorithm Pin
supercat93-Apr-09 6:22
supercat93-Apr-09 6:22 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945934-Apr-09 5:58
Member 41945934-Apr-09 5:58 
AnswerRe: Stable Quicksort algorithm [modified] Pin
bulg3-Apr-09 14:15
bulg3-Apr-09 14:15 
GeneralP.s. Pin
bulg3-Apr-09 14:28
bulg3-Apr-09 14:28 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945934-Apr-09 6:36
Member 41945934-Apr-09 6:36 
GeneralRe: Stable Quicksort algorithm Pin
bulg9-Apr-09 11:42
bulg9-Apr-09 11:42 
GeneralRe: Stable Quicksort algorithm Pin
Member 41945939-Apr-09 16:51
Member 41945939-Apr-09 16:51 
Ryan,

Thank you for the reply. swap_r won't work. Here is how to fix it. Move the indexed value out of the way to a temporary location. Now instead of swapping each element in the range with the indexed value (this is what won't work, you overlay all of the prior values on top of each other), just move the range in reverse (as you have done by decrementing t), finally opening space at the front of the range into which you can put the saved original indexed value. Instead of picking up two values and saving two values (a swap), you are just picking up a single value and saving the single value to a new location (a move). Half of the work. Of course, you have to decrement both of the move indexes as you move the data (the fix for the overlay in your original version).

Just about done with my original quicksort. I have found a MASM 8 bug along the way. MASM 8 will not accept:
movd qword ptr [base+index],xmm0 or movd xmm0,qword ptr [base+index]. The AMD manual specifically says movd works for both XMM and MMX as long as you specify a mem64 location. Not really a great problem, I just used a movq instead. I got into this because I just compared two extended floating values via the FPU and needed to swap them and tried to use MMX registers, however, the execution did not work (assembled without error, executed with no exceptions, but the array was not sorted). Seems that MMX and FPU share the same registers and control flags, and I guess you must finit the FPU before trying to use MMX. This is too time expensive, so I was just using XMM which is an independent register set. The only problem is that the code now depends on XMM instead of only MMX (my code was using an alignment specification of 8 to flag MMX OK, and an alignment of 16 to flag XMM OK. I may have to implement one more parameter which will just be used to enable MMX and/or XMM independently of the data alignment.

Dave.
QuestionVector orientation Question. Pin
Maximilien31-Mar-09 4:59
Maximilien31-Mar-09 4:59 
AnswerRe: Vector orientation Question. Pin
Luc Pattyn31-Mar-09 5:06
sitebuilderLuc Pattyn31-Mar-09 5:06 
GeneralRe: Vector orientation Question. Pin
Maximilien31-Mar-09 5:34
Maximilien31-Mar-09 5:34 
GeneralRe: whatever shape Pin
Luc Pattyn31-Mar-09 5:38
sitebuilderLuc Pattyn31-Mar-09 5:38 
GeneralRe: whatever shape Pin
Maximilien31-Mar-09 5:42
Maximilien31-Mar-09 5:42 
AnswerRe: Vector orientation Question. Pin
73Zeppelin31-Mar-09 5:13
73Zeppelin31-Mar-09 5:13 
AnswerRe: Vector orientation Question. Pin
Tim Craig31-Mar-09 8:26
Tim Craig31-Mar-09 8:26 
AnswerRe: Vector orientation Question. Pin
Roger Wright1-Apr-09 20:06
professionalRoger Wright1-Apr-09 20:06 
QuestionHow To Scramble Numbers On These Tables? [modified] Pin
Feranawati31-Mar-09 3:56
Feranawati31-Mar-09 3:56 
AnswerRe: How To Scramble Numbers On These Tables? Pin
Feranawati22-Apr-09 3:03
Feranawati22-Apr-09 3:03 
QuestionNeed help finding an Algorithm for a project [modified]-with image link Pin
dfreeser30-Mar-09 6:34
dfreeser30-Mar-09 6:34 
AnswerRe: Need help finding an Algorithm for a project Pin
Jörgen Andersson30-Mar-09 9:47
professionalJörgen Andersson30-Mar-09 9:47 
GeneralRe: Need help finding an Algorithm for a project Pin
dfreeser30-Mar-09 10:26
dfreeser30-Mar-09 10:26 
AnswerRe: Need help finding an Algorithm for a project [modified]-with image link Pin
dfreeser1-Apr-09 11:16
dfreeser1-Apr-09 11:16 
GeneralRe: Need help finding an Algorithm for a project [modified]-with image link Pin
73Zeppelin2-Apr-09 3:44
73Zeppelin2-Apr-09 3:44 
Questiontheory of grahp Pin
mini_25068927-Mar-09 8:00
mini_25068927-Mar-09 8:00 
AnswerRe: theory of grahp Pin
73Zeppelin30-Mar-09 2:45
73Zeppelin30-Mar-09 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.