An Animation of Quicksort

This page describes an animation of Quicksort. The animation was built using a prior version of Zeus, which was written in Modula-2+ and ran on the Firefly, one of the first multiprocessor workstations. Unfortunately, the code for performing this animation was decommissioned together with the Firefly.

The image above shows a naive parallel implementation of Quicksort. When the elements to be sorted have been partitioned into two groups, the partitioning thread recursively sorts one group, while a new thread is forked to sort the other group. Each thread has its own color, which is used to indicate the region and the elements on which it operates. The small window at the top of the screen, which displays the number of active threads, is the visual component of an "audio view" - the same information is represented by the pitch of a tone played through the workstation's speaker.

The image above presents a binary-tree view of the partitioning process. Each node in the tree represents a position in the array being sorted. Each subtree represents a block of elements to be sorted recursively; the block is partitioned into two groups separated by the root of the subtree. In the lower tree, the colors of nodes and edges reflect the threads assigned to partition each block. In the upper tree, red and blue colors are used to distinguish active blocks from inactive ones. While a block is being sorted, its node and the edge to its parent are red; they change to blue when the block is finished. Horizontal boxes represent unexamined blocks.

The image above compares three different quicksort implementations using the red/blue tree view. The top tree shows a sequential version - exactly one root-to-leaf path is active at any time. The naive parallel implementation is shown on the right - many threads are active at once. The left view shows a more sophisticated parallel algorithm. It sorts small blocks by selection sort (indicated by the unexpanded boxes), and forks a new thread only when the block to be sorted is large enough - in this view only two threads are active.


This animation is described in SRC Research Report 76a, and in an accompanying video tape, SRC Research Report 76b.


Zeus Home Page / Systems Research Center / Digital Equipment Corporation