Selection from heaps, row-sorted matrices and $X+Y$ using soft heaps
Abstract
We use soft heaps to obtain simpler optimal algorithms for selecting the $k$-th smallest item, and the set of~$k$ smallest items, from a heap-ordered tree, from a collection of sorted lists, and from $X+Y$, where $X$ and $Y$ are two unsorted sets. Our results match, and in some ways extend and improve, classical results of Frederickson (1993) and Frederickson and Johnson (1982). In particular, for selecting the $k$-th smallest item, or the set of~$k$ smallest items, from a collection of~$m$ sorted lists we obtain a new optimal "output-sensitive" algorithm that performs only $O(m+\sum_{i=1}^m \log(k_i+1))$ comparisons, where $k_i$ is the number of items of the $i$-th list that belong to the overall set of~$k$ smallest items.
- Publication:
-
arXiv e-prints
- Pub Date:
- February 2018
- DOI:
- 10.48550/arXiv.1802.07041
- arXiv:
- arXiv:1802.07041
- Bibcode:
- 2018arXiv180207041K
- Keywords:
-
- Computer Science - Data Structures and Algorithms;
- 68W05;
- F.2.2;
- E.1
- E-Print:
- 20 pages, 4 figures