2.2.7 • Published 9 years ago

kth-smallest v2.2.7

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

kth-smallest

Find kth smallest element in an arary of numbers

Uses a randomized quickselect to achieve O(n) average case time complexity

Build Status

Install

$ npm install kth-smallest

Usage

import kthSmallest from 'kth-smallest'

kthSmallest([10, 20, 30, 40], 0)
// 10

kthSmallest([10, 20, 30, 40], 2)
// 30

kthSmallest([10, 20, 30, 40], -1)
// 40

API

kthSmallest :: number a => [a] -> integer -> a

kthSmallest(numbers, k)

Arguments

  • numbers - An array of numbers
  • k - 0-indexed target (pass negative numbers for largest)
2.2.7

9 years ago

2.2.6

10 years ago

2.2.5

10 years ago

2.2.4

10 years ago

2.2.3

10 years ago

2.2.2

10 years ago

2.2.1

10 years ago

2.2.0

10 years ago

2.1.0

10 years ago

2.0.1

10 years ago