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)Interactive examples could not load. You can still copy the expressions.
Expected result: 3.