Table of Contents
Fetching ...

Deterministic Cache-Oblivious Funnelselect

Gerth Stølting Brodal, Sebastian Wild

TL;DR

This work resolves the open question of whether a deterministic cache-oblivious algorithm can match the I/O efficiency of randomized funnelselect for the multiple-selection problem. It introduces deterministic funnelselect, a cache-oblivious algorithm that uses a recursively applied, multi-way partitioning scheme driven by the query-rank entropy $\mathcal{B}$ and a carefully chosen subproblem size to avoid randomization. The main result proves worst-case bounds of $O(\mathcal{B} + N)$ comparisons and $O(\mathcal{B}_{I/O} + \frac{N}{B})$ I/Os under a tall-cache assumption $M \ge B^{1+\varepsilon}$, matching prior optimal I/O costs and closing the gap with deterministic guarantees. The analysis relies on a cache-oblivious $k$-partitioner and a potential-based accounting that ensures efficiency even when recursively processing only buckets containing unresolved ranks, with the funnel-like structure enabled by funnelsort guiding in-memory steps. This advances the understanding of the selection-to-sorting spectrum in the cache-oblivious model and enables deterministic, I/O-optimal algorithms for this natural generalization of selection and sorting.

Abstract

In the multiple-selection problem one is given an unsorted array $S$ of $N$ elements and an array of $q$ query ranks $r_1<\cdots<r_q$, and the task is to return, in sorted order, the $q$ elements in $S$ of rank $r_1, \ldots, r_q$, respectively. The asymptotic deterministic comparison complexity of the problem was settled by Dobkin and Munro [JACM 1981]. In the I/O model an optimal I/O complexity was achieved by Hu et al. [SPAA 2014]. Recently [ESA 2023], we presented a cache-oblivious algorithm with matching I/O complexity, named funnelselect, since it heavily borrows ideas from the cache-oblivious sorting algorithm funnelsort from the seminal paper by Frigo, Leiserson, Prokop and Ramachandran [FOCS 1999]. Funnelselect is inherently randomized as it relies on sampling for cheaply finding many good pivots. In this paper we present deterministic funnelselect, achieving the same optional I/O complexity cache-obliviously without randomization. Our new algorithm essentially replaces a single (in expectation) reversed-funnel computation using random pivots by a recursive algorithm using multiple reversed-funnel computations. To meet the I/O bound, this requires a carefully chosen subproblem size based on the entropy of the sequence of query ranks; deterministic funnelselect thus raises distinct technical challenges not met by randomized funnelselect. The resulting worst-case I/O bound is $O\bigl(\sum_{i=1}^{q+1} \frac{Δ_i}{B} \cdot \log_{M/B} \frac{N}{Δ_i} + \frac{N}{B}\bigr)$, where $B$ is the external memory block size, $M\geq B^{1+ε}$ is the internal memory size, for some constant $ε>0$, and $Δ_i = r_{i} - r_{i-1}$ (assuming $r_0=0$ and $r_{q+1}=N + 1$).

Deterministic Cache-Oblivious Funnelselect

TL;DR

This work resolves the open question of whether a deterministic cache-oblivious algorithm can match the I/O efficiency of randomized funnelselect for the multiple-selection problem. It introduces deterministic funnelselect, a cache-oblivious algorithm that uses a recursively applied, multi-way partitioning scheme driven by the query-rank entropy and a carefully chosen subproblem size to avoid randomization. The main result proves worst-case bounds of comparisons and I/Os under a tall-cache assumption , matching prior optimal I/O costs and closing the gap with deterministic guarantees. The analysis relies on a cache-oblivious -partitioner and a potential-based accounting that ensures efficiency even when recursively processing only buckets containing unresolved ranks, with the funnel-like structure enabled by funnelsort guiding in-memory steps. This advances the understanding of the selection-to-sorting spectrum in the cache-oblivious model and enables deterministic, I/O-optimal algorithms for this natural generalization of selection and sorting.

Abstract

In the multiple-selection problem one is given an unsorted array of elements and an array of query ranks , and the task is to return, in sorted order, the elements in of rank , respectively. The asymptotic deterministic comparison complexity of the problem was settled by Dobkin and Munro [JACM 1981]. In the I/O model an optimal I/O complexity was achieved by Hu et al. [SPAA 2014]. Recently [ESA 2023], we presented a cache-oblivious algorithm with matching I/O complexity, named funnelselect, since it heavily borrows ideas from the cache-oblivious sorting algorithm funnelsort from the seminal paper by Frigo, Leiserson, Prokop and Ramachandran [FOCS 1999]. Funnelselect is inherently randomized as it relies on sampling for cheaply finding many good pivots. In this paper we present deterministic funnelselect, achieving the same optional I/O complexity cache-obliviously without randomization. Our new algorithm essentially replaces a single (in expectation) reversed-funnel computation using random pivots by a recursive algorithm using multiple reversed-funnel computations. To meet the I/O bound, this requires a carefully chosen subproblem size based on the entropy of the sequence of query ranks; deterministic funnelselect thus raises distinct technical challenges not met by randomized funnelselect. The resulting worst-case I/O bound is , where is the external memory block size, is the internal memory size, for some constant , and (assuming and ).
Paper Structure (7 sections, 7 theorems, 3 figures, 1 table, 2 algorithms)

This paper contains 7 sections, 7 theorems, 3 figures, 1 table, 2 algorithms.

Key Result

Theorem 1

There exists a deterministic cache-oblivious algorithm solving the multiple-selection problem using $O(\mathcal{B} + N)$ comparisons and $O\bigl(\mathcal{B}_{\mathrm{I/O}} + \frac{N}{B}\bigr)$ I/Os in the worst case, assuming a tall cache $M\geq B^{1+\varepsilon}$.

Figures (3)

  • Figure 1: Example input with $N=15$, $q=4$ and $R[1..q]=[1,2,3,8]$. The expected output 3, 9, 15, 45 is obvious from the sorted array (right). (The sorted array is for illustration only; the goal of efficient multiple-selection algorithms is to avoid ever fully sorting the input.)
  • Figure 2: A $k$-partitioner for $k=16$ buckets. Content in the buffers is shaded; buffers are filled bottom-to-top; when full, they are flushed and then consumed from the bottom. The figure shows the situation where the input buffer for $P_6$ is being flushed down to its children (by partitioning elements around pivot $P_6$). The flush at $P_6$ was triggered during flushing $P_4$'s input buffer, which in turn has been called while flushing $P_8$ (the input). Buffer sizes for the three internal levels are shown next to the buffers. $k$-partitioners are defined recursively from a $\sqrt k$-partitioner at the top, a collection of $\sqrt k$ middle buffers, and $\sqrt k$ further $\sqrt k$-partitioners, each partitioning from one middle buffer to $\sqrt k$ output buffers. (All sizes here ignore floors and ceilings; for the precise definition valid for all $k$, see BrodalWild23.)
  • Figure 3: Deterministic multiple selection. The partition of an array $S$ into buckets $S_1,\ldots,S_4$ separated by pivots $P_1,\ldots,P_3$, and query ranks $r_1,\ldots,r_8$. In the example the maximum allowed bucket size is $\Delta=\Delta_1$, since $\Delta_1+\Delta_2+\Delta_3+\Delta_4+\Delta_6+\Delta_7+\Delta_8+\Delta_9 \geq |S|/2+1$ and $\Delta_2+\Delta_3+\Delta_4+\Delta_6+\Delta_7+\Delta_8+\Delta_9 < |S|/2+1$. Black squares are pivots and the shaded regions in buckets are the subproblems to recurse on.

Theorems & Definitions (10)

  • Theorem 1
  • Lemma 2: Blum, Floyd, Pratt, Rivest, Tarjan BFPRT73
  • Remark 3: Median of medians: I/O cost
  • Remark 4: Median of medians: duplicates
  • Lemma 5: Bleich, Overton BleichOverton83
  • Lemma 6: Frigo, Leiserson, Prokop, Ramanchandran FrigoLPR12, Brodal, Fagerberg BF02
  • Remark 7: Tall and taller
  • Lemma 8: Brodal and Wild BrodalWild23
  • Lemma 9
  • Theorem 10