Selection by sorting


function select( i : integer; var r : RecordArray; lo, up : integer ) : typekey; begin i := i+lo-1; if (i<lo) or (i>up) then Error {*** selection out of bounds ***} else begin sort( r, lo, up ); select := r[i].k end end;

Pascal source (521.sel.p)



© Addison-Wesley Publishing Co. Inc.