Online Square Packing with Gravity


We analyze the problem of packing squares in an online fashion: Given a semi-infinite strip of width 1 and an unknown sequence of squares of side length in [0,1] that arrive from above, one at a time. The objective is to pack these items as they arrive, minimizing the resulting height. Just like in the classical game of Tetris, each square must be moved along a collision-free path to its final destination. In addition, we account for gravity in both motion (squares must never move up) and position (any final destination must be supported from below). A similar problem has been considered before; the best previous result is by Azar and Epstein, who gave a 4-competitive algorithm in a setting without gravity (i.e., with the possibility of letting squares “hang in the air”) based on ideas of shelf packing: Squares are assigned to different horizontal levels, allowing an analysis that is reminiscent of some bin-packing arguments. We apply a geometric analysis to establish a competitive factor of 3.5 for the bottom-left heuristic and present a \(\frac{34}{13} \approx 2.6154\)-competitive algorithm.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10


  1. 1.

    That is, we take the square with the topmost bottom line. If there is more than one, we take the leftmost of these squares.

  2. 2.

    The charge to the bottom of \(\tilde{A}_{1}\) can be reduced to \(\frac{3}{4}\) by considering the larger one of the rectangles, R 1 and the one induced by Q, Q′, and P, as well as the triangle below the larger rectangle formed by \(D_{l}^{h}\) and \(D_{r}^{h}\). However, this does not lead to a better competitive ratio, because these costs are already dominated by the cost for holes of Type T.


  1. 1.

    Azar, Y., Epstein, L.: On two dimensional packing. J. Algorithms 25(2), 290–310 (1997)

    Article  MATH  MathSciNet  Google Scholar 

  2. 2.

    Baker, B.S., Schwarz, J.S.: Shelf algorithms for two-dimensional packing problems. SIAM J. Comput. 12(3), 508–525 (1983)

    Article  MATH  MathSciNet  Google Scholar 

  3. 3.

    Baker, B.S., Coffman, E.G. Jr., Rivest, R.L.: Orthogonal packings in two dimensions. SIAM J. Comput. 9(4), 846–855 (1980)

    Article  MATH  MathSciNet  Google Scholar 

  4. 4.

    Baker, B.S., Brown, D.J., Katseff, H.P.: A 5/4 algorithm for two-dimensional packing. J. Algorithms 2(4), 348–368 (1981)

    Article  MATH  MathSciNet  Google Scholar 

  5. 5.

    Balogh, J., Békési, J., Galambos, G.: New lower bounds for certain classes of bin packing algorithms. In: Proc. 8th Internat. Workshop Approx. Online Algor. Lect. Notes Comput. Sci., vol. 6534, pp. 25–36 (2010)

    Google Scholar 

  6. 6.

    Breukelaar, R., Demaine, E.D., Hohenberger, S., Hoogeboom, H.J., Kosters, W.A., Liben-Nowell, D.: Tetris is hard, even to approximate. Int. J. Comput. Geom. Appl. 14(1–2), 41–68 (2004)

    Article  MATH  MathSciNet  Google Scholar 

  7. 7.

    Brown, D.J., Baker, B.S., Katseff, H.P.: Lower bounds for on-line two-dimensional packing algorithms. Acta Inform. 18(2), 207–225 (1982)

    Article  MATH  MathSciNet  Google Scholar 

  8. 8.

    Brucker, P.: Scheduling Algorithms, 2nd edn. Springer, Berlin (2004)

    Google Scholar 

  9. 9.

    Coffman, E.G. Jr., Garey, M.R., Johnson, D.S., Tarjan, R.E.: Performance bounds for level-oriented two-dimensional packing algorithms. SIAM J. Comput. 9(4), 808–826 (1980)

    Article  MATH  MathSciNet  Google Scholar 

  10. 10.

    Coffman, E.G. Jr., Downey, P.J., Winkler, P.: Packing rectangles in a strip. Acta Inform. 38(10), 673–693 (2002)

    Article  MATH  MathSciNet  Google Scholar 

  11. 11.

    Csirik, J., Woeginger, G.J.: Shelf algorithms for on-line strip packing. Inf. Process. Lett. 63(4), 171–175 (1997)

    Article  MathSciNet  Google Scholar 

  12. 12.

    Epstein, L., van Stee, R.: Online square and cube packing. Acta Inform. 41, 595–606 (2005)

    Article  MATH  MathSciNet  Google Scholar 

  13. 13.

    Fekete, S.P., Schepers, J.: New classes of lower bounds for bin packing problems. In: Proceedings of the 6th International Conference on Integer Programming and Combinatorial Optimization (IPCO’98). Lecture Notes in Computer Science, vol. 1412, pp. 257–270. Springer, Berlin (1998)

    Google Scholar 

  14. 14.

    Fekete, S.P., Schepers, J., van der Veen, J.: An exact algorithm for higher-dimensional orthogonal packing. Oper. Res. 55, 569–587 (2007)

    Article  MATH  MathSciNet  Google Scholar 

  15. 15.

    Fekete, S.P., Kamphans, T., Schweer, N.: Online square packing. In: Proceedings of the 11th Algorithms and Data Structures Symposium (WADS’09). Lecture Notes in Computer Science, vol. 5664, pp. 302–314. Springer, Berlin (2009)

    Google Scholar 

  16. 16.

    Galambos, G., Frenk, J.B.G.: A simple proof of Liang’s lower bound for online bin packing and the extension to the parametric case. Discrete Appl. Math. 41(2), 173–178 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  17. 17.

    Galambos, G., Woeginger, G.J.: Online bin packing—a restricted survey. Math. Methods Oper. Res. 42(1), 25–45 (1995)

    Article  MATH  MathSciNet  Google Scholar 

  18. 18.

    Graham, R.L.: Bounds on multiprocessing timing anomalies. SIAM J. Appl. Math. 17(2), 416–429 (1969)

    Article  MATH  MathSciNet  Google Scholar 

  19. 19.

    Han, X., Iwama, K., Ye, D., Zhang, G.: Strip packing vs. bin packing. In: Proceedings of the 3rd International Conference on Algorithmic Aspects in Information and Management (AAIM’07). Lecture Notes in Computer Science, vol. 4508, pp. 358–367. Springer, Berlin (2007)

    Google Scholar 

  20. 20.

    Kenyon, C., Rémila, E.: Approximate strip packing. In: Proceedings of the 37th Annual IEEE Symposium on Foundations of Computer Science, (FOCS’96), pp. 31–36. IEEE Comput. Soc., Los Alamitos (1996)

    Google Scholar 

  21. 21.

    Schiermeyer, I.: Reverse-fit: A 2-optimal algorithm for packing rectangles. In: Proceedings of the 2nd Annual European Symposium on Algorithms (ESA’94). Lecture Notes in Computer Science, vol. 855, pp. 290–299. Springer, Berlin (1994)

    Google Scholar 

  22. 22.

    Seiden, S.S.: On the online bin packing problem. J. ACM 49(5), 640–671 (2002)

    Article  MathSciNet  Google Scholar 

  23. 23.

    Sleator, D.D.: A 2.5 times optimal algorithm for packing in two dimensions. Inf. Process. Lett. 10(1), 37–40 (1980)

    Article  MATH  MathSciNet  Google Scholar 

  24. 24.

    Steinberg, A.: A strip-packing algorithm with absolute performance bound 2. SIAM J. Comput. 26(2), 401–409 (1997)

    Article  MATH  MathSciNet  Google Scholar 

  25. 25.

    van Vliet, A.: An improved lower bound for online bin packing algorithms. Inf. Process. Lett. 43(5), 277–284 (1992)

    Article  MATH  Google Scholar 

  26. 26.

    Ye, D., Han, X., Zhang, G.: A note on online strip packing. J. Comb. Optim. 17(4), 417–423 (2009)

    Article  MATH  MathSciNet  Google Scholar 

Download references

Author information



Corresponding author

Correspondence to Sándor P. Fekete.

Additional information

Tom Kamhans was supported by DFG grant FE 407/8-3, project “ReCoNodes”. A preliminary extended abstract summarizing the results of this paper appeared in [15].

Rights and permissions

Reprints and Permissions

About this article

Cite this article

Fekete, S.P., Kamphans, T. & Schweer, N. Online Square Packing with Gravity. Algorithmica 68, 1019–1044 (2014).

Download citation


  • Online packing
  • Strip packing
  • Squares
  • Gravity
  • Tetris