fast-median
v1.1.0
Published
Find median of an array in amortized linear time
Downloads
19
Readme
fast-median
Find median element in an arary of numbers
Uses a randomized quickselect to achieve O(n) average case time complexity
Install
$ npm install fast-median
Usage
import median from 'fast-median'
median([10, 20, 30, 40])
// 25
median([10, 20, 30, 40, 50])
// 30
median([1])
// 1
API
median :: number a => [a] -> a
median(numbers)
Arguments
numbers
- An array of numbers