linear-partitioning
Given an array of numbers, partition them into a number of buckets, preserving order, where the ranges of each bucket are as close as possible.
npm install linear-partitioning
Want to see pretty graphs? Log in now!
9 | downloads in the last week |
17 | downloads in the last month |
Last Published By | |
---|---|
Version | 0.3.1 last updated 6 months ago |
License | BSD-2-Clause |
Keywords | linear, partition, algorithm, problem, buckets |
Repository | https://github.com/the-swerve/linear-partitioning.git (git) |
Bugs | https://github.com/the-swerve/linear-partitioning/issues |
Dependencies | None |
The Partition Problem
See http://www8.cs.umu.se/kurser/TDBAfl/VT06/algorithms/BOOK/BOOK2/NODE45.HTM
Input: given an array of S non-negative numbers and an integer k (the number of partitions we want)
Output: Partition S into k ranges, so as to minimize the maximum sum over all the ranges.
var partition = require('linear-partitioning');
partition([1,2,3,4,5,6,7,8,9], 3);
> [[1,2,3,4,5], [6,7], [8,9]]