HP Forums
(12C) Bubble Sort - Printable Version

+- HP Forums (http://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Bubble Sort (/thread-10738.html)



(12C) Bubble Sort - Gamo - 05-13-2018 06:47 AM

Going through old forum and saw very interesting topic about HP-12C
Hidden Indirect Register Access by the use of the CFj and RCL CFj functions to store and recall indirectly through the [n] Register.

I like to share this program and see if anyone can put this routine into other useful program or improve this sorting program.

Bubble Sort:

Procedure:
Put Data into CFj > RCL [n] > R/S
Data From largest to smallest start from Register R0 - Rx
Example if total of 10 data that will be from R0-R9 // R0 Largest R9 Smallest

f FIN > f REG // Clear Financial and Register
11 CFj
19 CFj
13 CFj
17 CFj
20 CFj

RCL [n] > 5 R/S > 0

11 19 13 17 20 (Unsort)
---------------------------
20 19 17 13 11 (Sorted)

RCL 0 > 20
RCL 1 > 19
RCL 2 > 17
RCL 3 > 13
RCL 4 > 11



Program:
Quote:STO [i]
1
STO [n]
RCL CFj
RCL CFj
X≤Y
X<>Y
CFj
RCL [i]
RCL [n]
1
+
X≤Y
GTO 03
2
-
X=0
GTO 00
GTO 01

This program is Posted by Katie on 26 Oct 2003
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv013.cgi?read=45179

Gamo