Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!psuvm!cunyvm!byuvax!zebolskyd From: zebolskyd@yvax.byu.edu Newsgroups: comp.lang.modula2 Subject: Re: Quicksort vs. Heapsort Message-ID: <838zebolskyd@yvax.byu.edu> Date: 5 Oct 89 04:00:18 GMT Lines: 17 Perhaps it would help if I described what I remember seeing in the QuickBasic demo that did visual sorts. The algorithm that was (perhaps erroneously) labelled a "Heap Sort" started out with a nice colorful mess of unsorted elements displayed as vertical bars of various heights and corresponding colors. One element was then selected (the criteria for the selection was not apparent, but appeared to be the leftmost element) and moved to the far left. Then the next unsorted element was moved to the right of where the first was deposited, and swapped with it if it was smaller. The next element to be sorted was moved to the left of the pair, and exchanged with its immediate left neighbor until the neighbor was smaller. The process continued in this manner, with each unsorted element being placed at the right edge of what was presumably termed the "heap" and swapped, one step at a time, until it found its place. Painfully slow, especially for the latter elements. How does a _real_ heapsort work? Lyle D. Gunderson zebolskyd@yvax.byu.edu