Quick Sort

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Post Reply
arhtur
Posts: 5
Joined: Mon Feb 22, 2021 3:18 am

Quick Sort

Post by arhtur »

The program Quicksort.raw sorts numbers in registers 0 to 99. On program line 11 is the size (100 = registers 0 to 99). You can use the program Filla.raw to fill registers 0 to 99 with random numbers. If you do XEQ Q9, it will put the random numbers into matrix MM, which you can edit to view numbers. To sort the numbers, do XEQ QS. You can edit matrix MM again to view the sorted numbers. If the numbers are sorted already and you run quick sort again, it may fail, since Quicksort does not do well with a sorted set of numbers, since the pivot point is not ideal. This non-recursive algorithm is a public domain version by Darel Rex Finley. This implementation has not been optimized to use the fewest instructions - I just attempted to translate the code from a C version. I have also ported this to the HP 35s, if anyone is interested.
Attachments
quicksort.raw
(445 Bytes) Downloaded 125 times
filla.raw
(50 Bytes) Downloaded 123 times
Post Reply