scispace - formally typeset
Journal ArticleDOI

Algorithm 63: partition

C. A. R. Hoare
- 01 Jul 1961 - 
- Vol. 4, Iss: 7, pp 321
TLDR
The procedures RANGESUB, RANGEMPY, and RANGEDVD provide for the remaining fundamental operations in range ari thmetic, and real a, b, c, d, e, f is a non-local real procedure.
Abstract
b e g i n p r o c e d u r e RANGESUM (a, b, c, d, e, f); rea l a , b , c , d , e , f ; c o m m e n t The term \"range number\" was used by P. S. Dwyer, Linear Computations (Wiley, 1951). Machine procedures for range ari thmetic were developed about 1958 by Ramon Moore, \"Automatic Error Analysis in Digital Computa t ion ,\" LMSD Report 48421, 28 Jan. 1959, Lockheed Missiles and Space Division, Palo Alto, California, 59 pp. If a _< x -< b and c ~ y ~ d, then RANGESUM yields an interval [e, f] such tha t e =< (x + y) f. Because of machine operation (truncation or rounding) the machine sums a -4c and b -4d may not provide safe end-points of the output interval. Thus RANGESUM requires a non-local real procedure ADJUSTSUM which will compensate for the machine ari thmetic. The body of ADJUSTSUM will be dependent upon the type of machine for which it is wri t ten and so is not given here. (An example, however, appears below.) I t is assumed tha t ADJUSTSUM has as parameters real v and w, and integer i, and is accompanied by a non-local real procedure CORRECTION which gives an upper bound to the magnitude of the error involved in the machine representat ion of a number. The output ADJUSTSUM provides the left end-point of the output interval of RANGESUM when ADJUSTSUM is called with i = --1, and the right end-point when called with i = 1 The procedures RANGESUB, RANGEMPY, and RANGEDVD provide for the remaining fundamental operations in range ari thmetic. RANGESQR gives an interval within which the square of a range nmnber must lie. RNGSUMC, RNGSUBC, RNGMPYC and RNGDVDC provide for range ari thmetic with complex range arguments, i.e. the real and imaginary parts are range numbers~ b e g i n e := ADJUSTSUM (a, c, 1 ) ; f : = ADJUSTSUM (b, d, 1) end RANGESUM; p r o c e d u r e RANGESUB (a, b, c, d, e, f) ; real a, b ,c , d ,e , f; c o m m e n t RANGESUM is a non-local procedure; b e g i n RANGESUM (a, b, d , --c, e, f) en d RANGESUB ; p r o c e d u r e RANGEMPY (a, b, c, d, e, f); real a, b, c, d, e, f; c o m m e n t ADJUSTPROD, which appears at the end of this procedure, is analogous to ADJUSTSUM above and is a nonlocal real procedure. MAX and MIN find the maximum and minimum of a set of real numbers and are non-local; b e g i n rea l v, w; i f a < 0 A c => 0 t h e n 1: b e g i n v : = c ; c : = a ; a : = v ; w : = d ; d : = b ; b : = w end 1; i f a => O t h e n 2: b e g i n i f c >= 0 t h e n 3 :beg in e : = a X e ; f := b X d ; g o t o 8 e n d 3 ; e : = b X c ; i f d ~ 0 t h e n 4: b e g i n f : = b X d ; g o t o 8 e n d 4; f : = a X d ; g o t o 8 5: e n d 2; i f b > 0 t h e n 6: b e g i n i f d > 0 t h e n b e g i n e := MIN(a X d, b X c); f : = MAX(a X c , b X d); go t o 8 e n d 6; e : = b X c; f : = a X c; go t o 8 e n d 5; f : = a X c ; i f d _-< O t h e n 7: b e g i n e : = b X d ; g o t o 8 e n d 7 ; e : = a X d ; 8: e : = ADJUSTPROD (e, 1 ) ; f := ADJUSTPROD (f, 1) e n d RANGEMPY; p r o c e d u r e RANGEDVD (a, b, c, d, e, f) ; real a, b, c, d, e, f; c o m m e n t If the range divisor includes zero the program exists to a non-local label \"zerodvsr\" . RANGEDVD assumes a non-local real procedure ADJUSTQUOT which is analogous (possibly identical) to ADJUSTPROD; b e g i n i f c =< 0 A d ~ 0 t h e n go to zer0dvsr; i f c < 0 t h e n 1: b e g i n i f b > 0 t h e n 2: b e g i n e : = b /d ; go t o 3 e n d 2; e : = b /c ; 3: i f a -->_ 0 t h e n 4: b e g i n f : = a /c ; go to 8 e n d 4; f : = a /d ; go to 8 e n d 1 ; i f a < 0 t h e n 5: b e g i n e : = a/c; go t o 6 e n d 5 ; e : = a /d ; 6: i f b > 0 t h e n 7: b e g i n f : = b/c ; go t o 8 e n d 7 ; f : = b /d ; 8: e := ADJUSTQUOT (e, 1 ) ; f : = ADJUSTQUOT (f,1) e n d RANGEDVD ; p r o c e d u r e RANGESQR (a, b, e, f); rea l a, b, e, f; c o m m e n t ADJUSTPROD is a non-10cal procedure; b e g i n i f a < 0 t h e n

read more

Citations
More filters
Journal ArticleDOI

Parallel Processing with the Perfect Shuffle

TL;DR: Given a vector of N elements, the perfect shuffle of this vector is a permutation of the elements that are identical to aperfect shuffle of a deck of cards.
Journal ArticleDOI

Expected time bounds for selection

TL;DR: A new selection algorithm is presented which is shown to be very efficient on the average, both theoretically and practically.
Journal ArticleDOI

Fast parallel GPU-sorting using a hybrid algorithm

TL;DR: The algorithm is of complexity nlogn, and for lists of 8 M elements and using a single Geforce 8800 GTS-512, it is 2.5 times as fast as the bitonic sort algorithms, with standard complexity of n(logn)^2.
Journal ArticleDOI

The contraction method for recursive algorithms

TL;DR: A new quite general model for branching dynamical systems is introduced and the contraction method can be applied in this model and this model includes many classical examples of random trees and gives a general frame for further applications.
Journal ArticleDOI

Output-Sensitive Algorithms for Computing Nearest-Neighbour Decision Boundaries

TL;DR: Output-sensitive algorithms for computing this decision boundary for point sets on the line and in ℝ2 are developed, which is the best possible when parameterizing with respect to n and k.