searching/quickselect

Returns the n-th smallest element of list within lo..hi inclusive (i.e. lo <= n <= hi).

Time complexity: O(N).
Source:
Parameters:
Name Type Description
arr Array Input array.
n Number A number of an element.
lo Number Low index.
hi Number High index.
Returns:
Returns n-th smallest element.
Example
var quickselect = require('path-to-algorithms/src/searching/'+
'quickselect').quickselect;
var result = quickselect([5, 1, 2, 2, 0, 3], 1, 0, 5);
console.log(result); // 1