(28S) Sorting lists - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (28S) Sorting lists (/thread-47.html) |
(28S) Sorting lists - Damien - 12-12-2013 02:26 PM Hi everyone, This small program takes a list in the stack and returns the sorted list using the bubble sort algorithm. Code:
Bubble sort is not very efficient as sorting method, but the algorithm is simple to understand. Another method more efficient is the selection sort: Code:
One more, with insertion method this time ! Code:
Damien. RE: [HP 28S] Sorting lists - C.Ret - 02-16-2014 08:19 PM (12-12-2013 02:26 PM)Damien Wrote: [...]Bubble sort is not very efficient as sorting method, but the algorithm is simple to understand. That's right. And another advantage of this sorting method with any RPL calculator is that it can easely be organize into the stack using the appropriate ROLL and ROLLD instructions. The 'bubbles' are pop up the stack with a SWAP after each comparison. The following code sorts a list the same way your code do it, but in a shorter and simpler way. Code:
But I am unable to say if this code is neither a true bubble sort, selection or insertion sort algorithm!? Perhaps may we call it the Rolling Stack Sorting Algorithm? RE: [HP 28S] Sorting lists - Thomas Klemm - 02-17-2014 09:29 PM From W.C. Wickes' paper "RPL: A Mathematical Control Language": Cheers Thomas |