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
QuickSort using recursion with LSTO command
QuickSort using recursion with LSTO command
- 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.
Re: QuickSort using recursion with LSTO command
CATALOG>DOWN>PRGM>LSTO
Cheers, Werner
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
Re: QuickSort using recursion with LSTO command
Thanks. I missed that.
Wayne
Wayne