We found a match
Your institution may have access to this item. Find your institution then sign in to continue.
- Title
Sorted.
- Authors
SWIERSTRA, WOUTER
- Abstract
The problem of the Dutch national flag was formulated by Dijkstra (1976) as follows: There is a row of buckets numbered from 1 to n. It is given that: P1:each bucket contains one pebbleP2:each pebble is either red, white, or blue.A minicomputer is placed in front of this row of buckets and has to be programmed in such a way that it will rearrange (if necessary) the pebbles in the order of the Dutch national flag.The minicomputer in question should perform this rearrangement using two commands: •swapi j for 1≤i≤n and 1≤j≤n exchanges the pebbles stored in the buckets numbered i and j;•read (i) for 1≤i≤n returns the colour of the pebble currently lying in bucket number i. Dijkstra originally named this operation buck.
- Subjects
FLAGS; PERSONAL computers; COMPUTER programming; COMMANDS (Logic); NUMERICAL analysis software; COMPUTATIONAL mathematics; COMPUTER operating systems
- Publication
Journal of Functional Programming, 2011, Vol 21, Issue 6, p573
- ISSN
0956-7968
- Publication type
Article
- DOI
10.1017/S0956796811000207