Journal articleAlgorithmica (2018)November 2017
Building Fences Straight and High: An Optimal Algorithm for Finding the Maximum Length You Can Cut k Times from Given Sticks
The Stick-Cutting Problem
Assume you have a supply of $n$ sticks of various lengths, say $L_1,\ldots,L_n$, and you need $k$ equally long pieces (as legs for a table; as posts for a fence; as boards for a shelf…).
What is the maximal length of the pieces you can get from these (without using glue)?
The problem is also called envy-free stick-division problem since—if we interpret the length of a stick as its value—cutting sticks as above ensures that we can produce $k$ maximal pieces that we can assign to $k$ players without inducing envy between them.
Origins and Applications
This elementary problem has various connections to other problems:
- envy-free cake cutting, see the stackexchange question that originally got us interested in the problem,
- the problem of proportional apportionment,
- and it appeared in a programming contest, and
- it is essentially a special case of the problem of selection from the (multiset-)union of sorted sequences. The Frederickson-Johnson algorithm solves the general problem optimally, but can be improved to linear time for the special sorted subsequences arising in the stick-cutting problem
Our Contribution
We analyze the structure of this problem and show that it essentially reduces to a single call of a selection algorithm; we thus obtain an optimal linear-time algorithm.
The core idea is to compute cheap upper and lower bounds for the cut length $l^\star$ of the $k$ pieces that we eventually use. This allows to reduce the set of lengths that we have to consider to $O(n)$ candidates. Using arguments of Cheng & Eppstein from an algorithm for the apportionment problem, we can find our optimal cut length $l^*$ by selecting the $k$th largest cut-length candidate.
Despite the simplicity of our algorithm, it did not seem to be known before.
Reference
Raphael Reitzig, Sebastian Wild: Building Fences Straight and High: An Optimal Algorithm for Finding the Maximum Length You Can Cut k Times from Given Sticks. Algorithmica 80, 11, pp 3365-3396 (Nov 2018). doi:10.1007/s00453-017-0392-3
BibTeX
@article{ReitzigWild2018,
title = {Building Fences Straight and High: An Optimal Algorithm for Finding the Maximum Length You Can Cut $k$ Times from Given Sticks},
author = {Raphael Reitzig and Sebastian Wild},
journal = {Algorithmica},
volume = {80},
number = {11},
pages = {3365--3396},
publisher = {Springer},
year = {2018},
doi = {10.1007/s00453-017-0392-3},
eprint = {1502.04048},
urlHidden = {https://www.wild-inter.net/publications/reitzig-wild-2018}
}
Timeline
- Feb 2015 arXiv 1502.04048
- Apr 2016 written
- Nov 2017 Algorithmica (2018)