An Algorithm for Bichromatic Sorting with Polylog Competitive Ratio

Authors Mayank Goswami , Riko Jacob

Thumbnail PDF


  • Filesize: 1.18 MB
  • 17 pages

Document Identifiers

Author Details

Mayank Goswami
  • Queens College CUNY, Flushing, New York, NY, USA
Riko Jacob
  • IT University of Copenhagen, Denmark


We want to thank an anonymous referee for pointing out another natural variant of bichromatic sorting.

Cite AsGet BibTex

Mayank Goswami and Riko Jacob. An Algorithm for Bichromatic Sorting with Polylog Competitive Ratio. In 15th Innovations in Theoretical Computer Science Conference (ITCS 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 287, pp. 56:1-56:17, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


The problem of sorting with priced information was introduced by [Charikar, Fagin, Guruswami, Kleinberg, Raghavan, Sahai (CFGKRS), STOC 2000]. In this setting, different comparisons have different (potentially infinite) costs. The goal is to find a sorting algorithm with small competitive ratio, defined as the (worst-case) ratio of the algorithm’s cost to the cost of the cheapest proof of the sorted order. The simple case of bichromatic sorting posed by [CFGKRS] remains open: We are given two sets A and B of total size N, and the cost of an A-A comparison or a B-B comparison is higher than an A-B comparison. The goal is to sort A ∪ B. An Ω(log N) lower bound on competitive ratio follows from unit-cost sorting. Note that this is a generalization of the famous nuts and bolts problem, where A-A and B-B comparisons have infinite cost, and elements of A and B are guaranteed to alternate in the final sorted order. In this paper we give a randomized algorithm InversionSort with an almost-optimal w.h.p. competitive ratio of O(log³ N). This is the first algorithm for bichromatic sorting with a o(N) competitive ratio.

Subject Classification

ACM Subject Classification
  • Theory of computation → Abstract machines
  • Theory of computation → Sorting and searching
  • Sorting
  • Priced Information
  • Nuts and Bolts


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Noga Alon, Manuel Blum, Amos Fiat, Sampath Kannan, Moni Naor, and Rafail Ostrovsky. Matching nuts and bolts. In Proceedings of the fifteenth annual ACM-SIAM Symposium on Discrete Algorithms (SODA'94), pages 690-696, 1994. Google Scholar
  2. Indranil Banerjee and Dana Richards. Sorting Under Forbidden Comparisons. In 15th Scandinavian Symposium and Workshops on Algorithm Theory (SWAT 2016), editors, Rasmus Pagh, volume 53 of Leibniz International Proceedings in Informatics (LIPIcs), pages 22:1-22:13, Dagstuhl, Germany, 2016. Schloss Dagstuhl - Leibniz-Zentrum für Informatik. URL:
  3. Michael A Bender, Mayank Goswami, Dzejla Medjedovic, Pablo Montes, and Kostas Tsichlas. Batched predecessor and sorting with size-priced information in external memory. In Latin American Symposium on Theoretical Informatics, pages 155-167. Springer, 2021. Google Scholar
  4. Moses Charikar, Ronald Fagin, Venkatesan Guruswami, Jon Kleinberg, Prabhakar Raghavan, and Amit Sahai. Query strategies for priced information. Journal of Computer and System Sciences, 64(4):785-819, 2002. Google Scholar
  5. Amol Deshpande, Lisa Hellerstein, and Devorah Kletenik. Approximation algorithms for stochastic boolean function evaluation and stochastic submodular set cover. In Proceedings of the twenty-fifth annual ACM-SIAM Symposium on Discrete Algorithms (SODA'14), pages 1453-1466. SIAM, 2014. Google Scholar
  6. Mayank Goswami and Riko Jacob. Universal sorting: Finding a dag using priced comparisons, 2022. URL:
  7. Mayank Goswami and Riko Jacob. An algorithm for bichromatic sorting with polylog competitive ratio, 2023. URL:
  8. Anupam Gupta and Amit Kumar. Sorting and selection with structured costs. In Proceedings 42nd IEEE Symposium on Foundations of Computer Science (FOCS'01), pages 416-425. IEEE, 2001. Google Scholar
  9. Zhiyi Huang, Sampath Kannan, and Sanjeev Khanna. Algorithms for the generalized sorting problem. In 2011 IEEE 52nd Annual Symposium on Foundations of Computer Science (FOCS'11), pages 738-747, 2011. URL:
  10. Haim Kaplan, Eyal Kushilevitz, and Yishay Mansour. Learning with attribute costs. In Proceedings of the thirty-seventh annual ACM symposium on Theory of computing (STOC'05), pages 356-365, 2005. Google Scholar
  11. János Komlós, Yuan Ma, and Endre Szemerédi. Matching nuts and bolts in O(n log n) time. SIAM Journal on Discrete Mathematics, 11(3):347-372, 1998. Google Scholar
  12. William Kuszmaul and Shyam Narayanan. Stochastic and worst-case generalized sorting revisited. In 2021 IEEE 62nd Annual Symposium on Foundations of Computer Science (FOCS'22), pages 1056-1067. IEEE, 2022. Google Scholar
  13. Shay Mozes, Krzysztof Onak, and Oren Weimann. Finding an optimal tree searching strategy in linear time. In In Proceedings of the Nineteenth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA'08), volume 8, pages 1096-1105, 2008. Google Scholar
  14. Krzysztof Onak and Pawel Parys. Generalization of binary search: Searching in trees and forest-like partial orders. In 2006 47th Annual IEEE Symposium on Foundations of Computer Science (FOCS'06), pages 379-388. IEEE, 2006. Google Scholar
  15. Manish Purohit, Zoya Svitkina, and Ravi Kumar. Improving online algorithms via ml predictions. Advances in Neural Information Processing Systems, 31, 2018. Google Scholar
  16. Gregory JE Rawlins. Compared to what? An introduction to the analysis of algorithms. Computer Science Press, Inc., 1992. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail