🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

kth-smallest

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kth-smallest

Find kth smallest element in an array of numbers in amortized linear time

2.2.7
latest
Source
npm
Version published
Weekly downloads
5
25%
Maintainers
1
Weekly downloads
 
Created
Source

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)

FAQs

Package last updated on 07 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts