Wilang Documentation1.0.0+4

partitionSelect#

Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.

Available in: math cells, REPL.

Syntax#

partitionSelect(x, k)
partitionSelect(x, k, compare)

Arguments and behavior#

For matrices, dimensions must match the operation. Singular matrices or incompatible shapes can fail. Cell indexing starts at 1. The example returns scalar (number).

Example#

Edit the inputs, then use Run or Reset. Changes stay in this example.

Example
partitionSelect([4,1,3,2],2)

Expected result: 3.

See also#

sort

All functions · Math guides