@bemoje/arr-partition-index

Linear-time Partitioning. Runtime: O(n). Chooses a pivot and re-arrages the array so that everything on the left is <= pivot and everything on the right is > pivot

Usage no npm install needed!

<script type="module">
  import bemojeArrPartitionIndex from 'https://cdn.skypack.dev/@bemoje/arr-partition-index';
</script>

README

@bemoje/arr-partition-index

Linear-time Partitioning. Runtime: O(n). Chooses a pivot and re-arrages the array so that everything on the left is <= pivot and everything on the right is > pivot

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

Installation

npm install @bemoje/arr-partition-index
npm install --save @bemoje/arr-partition-index
npm install --save-dev @bemoje/arr-partition-index

Usage

import arrPartitionIndex from '@bemoje/arr-partition-index'

const arr = [1, 2, 3, 4]

arrPartitionIndex(arr, 1, 2)
//=> 1

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

arrPartitionIndex

Linear-time Partitioning. Runtime: O(n). Chooses a pivot and re-arrages the array so that everything on the left is <= pivot and everything on the right is > pivot

Parameters
Returns

number pivot index