Efficient Algorithms for Sorting k-Sets in Bins

  • Atsuki Nagao
  • Kazuhisa Seto
  • Junichi Teruyama
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 8344)


We give efficient algorithms for Sorting k-Sets in Bins. The Sorting k-Sets in Bins problem can be described as follows: We are given numbered n bins with k balls in each bin. Balls in the i-th bin are numbered n − i + 1. We can only swap balls between adjacent bins. How many swaps are needed to move all balls to the same numbered bins. For this problem, we design an efficient greedy algorithm with \(\frac{k+1}{4}n^2+O(kn)\) swaps. As k and n increase, this approaches the lower bound of \(\lceil \binom{kn}{2}/(2k-1) \rceil\). In addition, we design a more efficient recursive algorithm using \(\frac{15}{16}n^2+O(n)\) swaps for the k = 3 case.


Greedy Mathematical puzzle Recursion Sorting Swap 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Bóna, M., Flynn, R.: Sorting a Permutation with Block Moves. arXiv:0806.2787v1Google Scholar
  2. 2.
    Martínez, C., Rösler, U.: Partial quicksort and quickpartitionsort. In: DMTCS Proceedings 2001, pp. 505–512 (2010)Google Scholar
  3. 3.
    Cranston, D., Sudborough, I.H., West, D.B.: Short Proofs for Cut-and-Paste Sorting of Permutations. Discrete Mathematics 307, 2866–2870 (2007)CrossRefzbMATHMathSciNetGoogle Scholar
  4. 4.
    Daskalakis, C., Karp, R.M., Mossel, E., Eiesenfeld, S.J., Verbin, E.: Sorting and selection in posets. SIAM Journal on Computing 40(3), 597–622 (2011)CrossRefzbMATHMathSciNetGoogle Scholar
  5. 5.
    Dweighter, H.: Elementary Problems. American Mathematical Monthly 82, 1010 (1975)CrossRefMathSciNetGoogle Scholar
  6. 6.
    Elizalde, S., Winkler, P.: Sorting by Placement and Shift. In: Proc. ACM/SIAM Symp. on Discrete Algorithms (SODA), pp. 68–75 (2009)Google Scholar
  7. 7.
    Eriksson, H., Eriksson, K., Karlander, J., Svensson, L., Wástlund, J.: Sorting a bridge hand. Discrete Math. 241, 289–300 (2001)CrossRefzbMATHMathSciNetGoogle Scholar
  8. 8.
    Faigle, U., Tuŕan, G.: Sorting and Recognition Problems for Ordered Sets. SIAM Journal on Computing 17(1), 100–113 (1988)Google Scholar
  9. 9.
    Gates, W.H., Papadimitriou, C.H.: Bounds for sorting by prefix reversal. Discrete Math. 27, 47–57 (1979)CrossRefMathSciNetGoogle Scholar
  10. 10.
    Heydari, M.H., Sudborough, I.H.: On the diameter of pancake network. J. Algorithms 25, 67–94 (1997)CrossRefzbMATHMathSciNetGoogle Scholar
  11. 11.
    Hoare, C.A.R.: PARTITION (Algorithm 63);QUICKSORT (Algorithm 64);FIND (Algorithm 65). Communication of the Association for Computing Machinery 4, 321–322 (1961)CrossRefGoogle Scholar
  12. 12.
    Ito, H., Teruyama, J., Yoshida, Y.: An almost optimal algorithm for winkler’s sorting pairs in bins. Progress in Informatics (9), 3–7 (2012)Google Scholar
  13. 13.
  14. 14.
    Winkler, P.: Mathematical Puzzles: A Connoisseur’s Collection. A K Peters 143, 149–151 (2004)Google Scholar
  15. 15.

Copyright information

© Springer International Publishing Switzerland 2014

Authors and Affiliations

  • Atsuki Nagao
    • 1
  • Kazuhisa Seto
    • 2
  • Junichi Teruyama
    • 3
    • 4
  1. 1.Kyoto UniversityJapan
  2. 2.Seikei UniversityJapan
  3. 3.National Institute of InformaticsJapan
  4. 4.JST, ERATO, Kawarabayashi Large Graph Projectc/o Global Research Center for Big Data MathematicsJapan

Personalised recommendations