Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: All Sorts of Sorts Message-ID: <432.UUL1.3#5129@willett.UUCP> Date: 9 Feb 90 23:05:28 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 28 Date: 02-08-90 (09:25) Number: 2874 (Echo) To: ZAFAR ESSAK Refer#: 2869 From: IAN GREEN Read: 02-08-90 (09:25) Subj: LEARN TO SORT Status: PUBLIC MESSAGE Sorting is a bit more subtle than you seem to realize. In my comm program, I use two sorts, one is the bubble sort where I sort the phone book, and the other is a stack oriented partition sort. Granted the bubble sort is slow on unordered random data, data that is already partially sorted can be sorted much faster with the bubble sort because it is able to exploit the partial ordering. Stack oriented sorts like the Quick Sort, cannot exploit this and thus are not all that suitable to partially ordered data like real data-bases. My phone book (in my comm program) is 500 entries, rather small compared to major data-bases, but still representative. Since I modify at most 2 or 3 entries, it makes sense to use the bubble sort since the data is already sorted from the last modification. Because it is always partially ordered at each modification, the logic of algorithm choice becomes obvious. My apologies for not having a Forth example for you. Ian Green NET/Mail : British Columbia Forth Board - Burnaby BC - (604)434-5886 ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'