2.2.7 • Published 8 years ago

kth-smallest v2.2.7

Weekly downloads
1
License
MIT
Repository
github
Last release
8 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

8 years ago

2.2.6

8 years ago

2.2.5

8 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.2

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago