Finding the Minimum Cost Acceptable Element in a Sorted Matrix

Authors Sebastián Urrutia , Vinicius dos Santos

Thumbnail PDF


  • Filesize: 0.64 MB
  • 14 pages

Document Identifiers

Author Details

Sebastián Urrutia
  • Molde University College, Norway
Vinicius dos Santos
  • Federal University of Minas Gerais, Brazil

Cite AsGet BibTex

Sebastián Urrutia and Vinicius dos Santos. Finding the Minimum Cost Acceptable Element in a Sorted Matrix. In 22nd International Symposium on Experimental Algorithms (SEA 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 301, pp. 28:1-28:14, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)


In this work we introduce the problem of finding a minimum cost acceptable element in an n × n matrix M whose columns and rows are sorted in non-decreasing order. More precisely, given a sorted matrix M and access to a given oracle function f: ℕ × ℕ → {True, False}, one has to find a pair (i, j) of indices such that f(i,j) returns True and the value M[i,j] is as small as possible. Assuming the computation of f(i,j) takes time bounded by a constant, a naive algorithm scanning all the positions of the matrix takes time O(n²). Another natural approach, based on a priority queue, takes time O(z log z) in which z stands for the position of the first pair of indices for which the oracle returns True in a sorted list of all elements of M. In the worst case, when z = n², the naive algorithm is better than the priority queue one. In this work we introduce different algorithms with complexities depending on n and z, such as O(n √z) and O(min(n²,z²)), and compare them, both theoretically and experimentally, in terms of running time and number of calls to the oracle. Among other things, we find that in most cases our algorithms do not make a significantly larger number of calls to the oracle than the priority queue-based algorithm, which achieves the minimum of such call when all elements of the matrix are distinct, while being much faster in large instances.

Subject Classification

ACM Subject Classification
  • Theory of computation → Design and analysis of algorithms
  • Search
  • Sorted matrix
  • Oracle function
  • Algorithm complexity


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


  1. Michel Cosnard, Jean Duprat, and Afonso G Ferreira. The complexity of searching in X+Y and other multisets. Information Processing Letters, 34(2):103-109, 1990. Google Scholar
  2. Greg Frederickson and Donald Johnson. The complexity of selection and ranking in X+Y and matrices with sorted columns. J. of Comput. and Syst. Sci., 24(2):197-208, 1982. Google Scholar
  3. Michael L Fredman. How good is the information theory bound in sorting? Theoretical Computer Science, 1(4):355-361, 1976. Google Scholar
  4. Haim Kaplan, László Kozma, Or Zamir, and Uri Zwick. Selection from heaps, row-sorted matrices, and X + Y using soft heaps. In Symposium on Simplicity in Algorithms, 2, pages 5:1-5:21, 2019. Google Scholar
  5. Jean-Luc Lambert. Sorting the sums (x_i + y_j) in O(n²) comparisons. Theoretical Computer Science, 103(1):137-141, 1992. Google Scholar
  6. Frank Meisel and Christian Bierwirth. Heuristics for the integration of crane productivity in the berth allocation problem. Transportation Research Part E: Logistics and Transportation Review, 45(1):196-209, 2009. URL:
  7. Andranik Mirzaian and Eshrat Arjomandi. Selection in X+Y and matrices with sorted rows and columns. Information Processing Letters, 20(1):13-17, 1985. Google Scholar