Screen Sleep
Volume Number: 1
Issue Number: 10
Column Tag: Ask Prof. Mac
“Screen Sleep in Assembly”
By Steve Brecher, President, Software Supply, MacTutor Contributing
Editor
BASIC Sort
David Smith, Editor of MacTutor, laments, "I wrote an MS BASIC program that
sorts an array of some 600 items (names). It takes over an hour! Absurd. It's a
simple bubble sort.
Q. How much time can be saved by an alternate sort algorithm in BASIC?
A. The bubble sort is a notoriously poor performer except on very small arrays.
Sorting algorithms and their performance are a well-studied subfield of computer
science. Two clever algorithms that have become popular outside of academia are
ShellSort and QuickSort; I'll discuss QuickSort because I'm more familiar with it.
In its pure form, QuickSort is a simple recursive algorithm that uses a "divide
and conquer" technique. Consider the elements of the array to be sorted as laid out
horizontally, so we can talk of the left and right portions of the array. If it is the case
that (1) some element of the array, called the partitioning element, is already in its
final position; (2) all the elements to the left of the partioning element are less than