In 6] Misra introduced the powerlist notation and used it to succintly describe several parallel algorithms. In particular, algorithms that use a balanced divide and conquer strategy have elegant descriptions as powerlist functions. Among the examples presented were two sorting networks due to Batcher 1]. To prove their correctness a-posteriori, Misra used the 0-1 principle, which states that a compare-and-swap sorting algorithm is correct ii it sorts all inputs consisting of 0s and 1s. Misra attributed the 0-1 principle to Knuth 3], where Batcher's networks are presented. One of Batcher's networks, the Bitonic Sort, can be derived as a parallel algorithm, as shown by Huang and Lengauer 2]. In this paper we study the odd-even sort which can be considered a parallel version of bubble sort; it is simple to implement and to explain operationally, yet it is ineecient and somewhat tedious to prove correct 0. The algorithm consists of a sequence of phases, where each phase consists of an \even" step followed by an \odd" step. It is often described operationally as follows 5]: At odd steps, we compare the contents of cells 1 and 2, 3 and 4, etc., exchanging values if necessary so that the smaller value ends up in the leftmost cell. At even steps, we perform the same operation for cells 2 and 3, 4 and 5, etc. In this paper we derive the odd-even sort and prove its correctness. In contrast to Batcher's networks, the odd-even sort is iterative in nature and does not have a simple deenition in the powerlist notation. Our derivation is somewhat surprising: from a simple characterization of what it means for a powerlist to be sorted, the algorithm emerges through a series of transformations. The remaining proof of correctness consists of proving that after a nite number of phases of the computation, odd-even sort reaches a xpoint, and that each phase produces a permutation of the input. In contrast to Misra's presentation 6] of Batcher's networks, we derive the odd-even sort, and our proofs of correctness do not use the 0-1 principle. 1 Preliminaries In this paper we use the notation and concepts that exist in the literature on powerlists 0, 4, 6]. As a convenience to the reader we give a brief introduction to the powerlist notation below. A powerlist is a linear data structure, whose elements are all of the same data type. The length of a …
[1]
F. Leighton,et al.
Introduction to Parallel Algorithms and Architectures: Arrays, Trees, Hypercubes
,
1991
.
[2]
Jayadev Misra,et al.
Powerlist: a structure for parallel recursion
,
1994,
TOPL.
[3]
William Adams,et al.
Verifying Adder Circuits Using Powerlists
,
1994
.
[4]
Christian Lengauer,et al.
The automated proof of a trace transformation for a bitonic sort
,
1986,
Theor. Comput. Sci..
[5]
Jacob Kornerup.
Mapping a Functional Notation for Parallel Programs Onto Hypercubes
,
1995,
Inf. Process. Lett..
[6]
Donald E. Knuth,et al.
The Art of Computer Programming, Vol. 3: Sorting and Searching
,
1974
.
[7]
K. E. Batcher,et al.
Sorting Networks and their Application
,
1968
.
[8]
Kenneth E. Batcher,et al.
Sorting networks and their applications
,
1968,
AFIPS Spring Joint Computing Conference.