03-05-1995 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³quicksort for HP48 gx/sx/g/s ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ this is a very fast ml prog to sort an array of real numbers. there are 2 progs: - qsort : recieves array or list of real numbers and produces a sorted array of the numbers. if this routine gets a list then it converts it to an array and that sorts. if it gets an array then it NEWOB it and then sort. - qshort : recieves only an array of reals and sorts it without NEWOBing it. it means that every var that refernce it will be changed and also other stack levels which are DUPed of it. the big adventage is that it doesn't need the extra memory for NEWObing it. note that qshort is only a subset of qsort so choose what you like. the sort routine works by the quicksort algorithm which is recursive and its complexity is O(N*logN) !. recursion is a problem in HP48 since it has fixed 8 level return stack so the program allocated memory for its own stack. this means that if you sort a 16Kbyte array then you will need 10Kbyte free to sort it (62.5% of the array). however the prog is very fast. it can sort an array of 1200 reals in less then 3 secs ( HP48G 's internal sort routine takes few minutes ). this program was done as a practice of ML programming on the 48 and was tested only on HP48GX-P (also it should work on all vertions). the prog is FREEWARE. but I'm not liable to any dammage that can/would happen so use this prog on your own responsebility. if there are bugs I will be glad to hear and fix them. Tamir Demri email : s2543671@techst02.technion.ac.il