CCG_KTHx

Returns the Kth smallest value in an array

Description:

This routine returns the value of the Kth smallest element in the given array. It is an implementation of an algorithm of Niklaus Wirth from the book " Algorithms + data structures = programs" .

Invocation

CALL CCG_KTHx( EL, K, ARRAY, ANCDAT, VALUE, STATUS )

Arguments

EL = INTEGER (Given)
The number of elements in the input array.
K = INTEGER (Given and Returned)
On entry the ordered value to be returned, on exit index of ARRAY that contain the Kth smallest value.
ARRAY( EL ) = ? (Given and Returned)
The array of values to be processed. Note this is modified on exit.
ANCDAT( EL ) = INTEGER (Given and Returned)
Array of data whose association with ARRAY is to be preserved (such as a list of pointers to the original positions within ARRAY).
VALUE = ? (Returned)
The Kth smallest value in the input array.
STATUS = INTEGER (Given)
The global status.

Notes: