# select and partition

(classic problem)

**Definition:**
Given an *array* A of n elements and a positive integer k ≤ n, find the k^{th} smallest element of A and *partition* the array such that A[1], …, A[k-1] ≤ A[k] ≤ A[k+1], …, A[n].

**See also**
*select k*^{th} element, *Select*, *MODIFIND*, *Find*.

*Note:
Algorithms to solve this problem are often used in **sort* algorithms or to find the *median* of a set. These can be easily changed to find the k^{th} largest element.

Author: VZ

## Implementation

Vladimir Zabrodsky's analysis and comparison (Rexx)

Go to the
Dictionary of Algorithms and Data
Structures home page.

If you have suggestions, corrections, or comments, please get in touch
with Paul Black.

Entry modified 2 March 2015.

HTML page formatted Wed Mar 13 12:42:46 2019.

Cite this as:

Vladimir Zabrodsky, "select and partition", in
*Dictionary of Algorithms and Data Structures* [online], Paul E. Black, ed. 2 March 2015. (accessed TODAY)
Available from: https://www.nist.gov/dads/HTML/selectAndPartition.html