QuickSort using recursion with LSTO command

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
Calcman54
Posts: 36
Joined: Sat Mar 10, 2018 12:24 am
Location: Toronto Canada

QuickSort using recursion with LSTO command

Post by Calcman54 »

This version of QuickSort stores the sort data, maximum 1000, in registers 00 to N-1. It sorts, in ascending order, a specified number of random numbers, between 0 and 1. The previous version, posted on October,5 2023, used a matrix for data storage.

It uses the Free42 extension command LSTO (Local store), in the recursive QCK routine, to store copies of two local variables. A link to the decription for this very useful function is shown below. LSTO removes the need of the program to save and restore local variables.

https://thomasokken.com/free42/#xfcn:~: ... n%20Free42

LSTO is not available in the CATALOG (See correction from Werner in next post) so it must be typed in manually as XEQ "LSTO". This will be resolved to LSTO.

To use this program enter N then press XEQ QSort.

The program will verify that the sort is successful and, if so, will return 0 in the X stack register. The Y stack register contai ns the sort time in seconds.

The sorted numbers can be viewed by entering XEQ VIEW. There is a pause after each value.

The attached spreadsheet contains the program listing and some time trial results.

Wayne
Attachments
QSortR2.raw
(310 Bytes) Downloaded 16 times
DM42 QuickSort using Registers and LSTO.xlsx
(16.86 KiB) Downloaded 22 times
Last edited by Calcman54 on Mon Nov 20, 2023 7:21 pm, edited 1 time in total.
whuyse
Posts: 193
Joined: Thu Dec 21, 2017 1:23 pm

Re: QuickSort using recursion with LSTO command

Post by whuyse »

Calcman54 wrote:
Sun Nov 19, 2023 1:14 am
LSTO is not available in the CATALOG so it must be typed in manually as XEQ "LSTO". This will be resolved to LSTO.
CATALOG>DOWN>PRGM>LSTO

Cheers, Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
Calcman54
Posts: 36
Joined: Sat Mar 10, 2018 12:24 am
Location: Toronto Canada

Re: QuickSort using recursion with LSTO command

Post by Calcman54 »

Thanks. I missed that.

Wayne
Post Reply