, Volume 80, Issue 11, pp 3365–3396 | Cite as

Building Fences Straight and High: An Optimal Algorithm for Finding the Maximum Length You Can Cut k Times from Given Sticks

  • Raphael Reitzig
  • Sebastian Wild


Given a set of n sticks of various (not necessarily different) lengths, what is the largest length so that we can cut k equally long pieces of this length from the given set of sticks? 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. This algorithm also solves the related envy-free stick-division problem, which Segal-Halevi et al. (ACM Trans Algorithms 13(1):1–32, 2016. ISSN: 15496325. recently used as their central primitive operation for the first discrete and bounded envy-free cake cutting protocol with a proportionality guarantee when pieces can be put to waste.


Envy-free stick division Envy-free allocations Fair division Building fences Stick cutting Cake cutting with waste proportional apportionment 



Erel Segal-Halevi ( posed the original question [11] on Computer Science Stack Exchange. Our approach is based on observations in the answers by Abhishek Bansal (user1990169(, InstructedA ( and FrankW ( Hence, even though the eventual algorithm and its presentation have been developed and refined offline with the use of a blackboard and lots of paper, the result has been the product of a small “crowd” collaboration made possible by the Stack Exchange platform. We thank Chao Xu for pointing us towards the work by Cheng and Eppstein [6], and for providing the observation we utilize in Sect. 4.1.


  1. 1.
    Aziz, H., Mackenzie, S.: A discrete and bounded envy-free cake cutting protocol for any number of agents. In: Annual Symposium on Foundations of Computer Science (FOCS), pp. 416–427. IEEE (2016).
  2. 2.
    Blum, M., Floyd, R.W., Pratt, V., Rivest, R.L., Tarjan, R.E.: Time bounds for selection. J. Comput. Syst. Sci. 7(4), 448–461 (1973). MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Brandt, F., Conitzer, V., Endriss, U., Lang, J., Procaccia, A.D. (eds.): Handbook of Computational Social Choice. Cambridge University Press, Cambridge (2016). ISBN: 978-1-107-06043-2Google Scholar
  4. 4.
    Brams, S.J., Taylor, A.D.: Fair Division. Cambridge University Press, Cambridge (1996). ISBN: 978-0-521-55644-6Google Scholar
  5. 5.
    Balinski, M.L., Young, H.P.: Fair Representation: Meeting the Ideal of One Man, One Vote, 2nd edn. Brookings Institution Press, Washington (2001). ISBN: 978-0-81-570111-8Google Scholar
  6. 6.
    Cheng, Z., Eppstein, D.: Linear-time algorithms for proportional apportionment. In: International Symposium on Algorithms and Computation (ISAAC) 2014. Springer (2014).
  7. 7.
    Graham, R.L., Knuth, D.E., Patashnik, O.: Concrete Mathematics: A Foundation for Computer Science. Addison-Wesley (1994). ISBN: 978-0-20-155802-9Google Scholar
  8. 8.
    Morland, T.: Building Fences (Programming Exercise from the IDI-Open 2016 Programming Contest) (2016). (visited on 02/13/2017)
  9. 9.
    Pukelsheim, F.: Proportional Representation. Apportionment Methods and Their Applications, 1st edn. Springer, Berlin (2014). ISBN: 978-3-319-03855-1
  10. 10.
    Reitzig, R., Wild S.: A Practical and Worst-Case Efficient Algorithm for Divisor Methods of Apportionment (2015). arXiv: 1504.06475
  11. 11.
    Segal-Halevi, E.: Cutting equal sticks from different sticks (2014). (visited on 02/16/2015)
  12. 12.
    Segal-Halevi, E., Hassidim, A., Aumann, Y.: Waste makes haste: bounded time protocols for envy-free cake cutting with free disposal. In: The 14th International Conference on Autonomous Agents and Multiagent Systems (AAMAS), May (2015)Google Scholar
  13. 13.
    Segal-Halevi, E., Hassidim, A., Aumann, Y.: Waste makes haste: bounded time algorithms for envy-free cake cutting with free disposal. ACM Trans. Algorithms 13(1), 1–32 (2016). ISSN: 15496325.

Copyright information

© Springer Science+Business Media, LLC 2017

Authors and Affiliations

  1. 1.University of KaiserslauternKaiserslauternGermany
  2. 2.David R. Cheriton School of Computer ScienceUniversity of WaterlooWaterlooCanada

Personalised recommendations