c8-4 (779527), страница 2
Текст из файла (страница 2)
For selection,we can ignore one subset and attend only to the one that contains our desired kthelement. Selection by partitioning thus does not need a stack of pending operations,and its operations count scales as N rather than as N log N (see [1]). Comparisonwith sort in §8.2 should make the following routine obvious:Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited.
To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).void rank(unsigned long n, unsigned long indx[], unsigned long irank[])Given indx[1..n] as output from the routine indexx, returns an array irank[1..n], thecorresponding table of ranks.{unsigned long j;.















