Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Selection and Sorting in the “Restore” Model

Published: 16 April 2018 Publication History

Abstract

We consider the classical selection and sorting problems in a model where the initial permutation of the input has to be restored after completing thecomputation. Such algorithms are useful for designing space-efficient algorithms, when one encounters subproblems that have to be solved by subroutines. It is important that these subroutines leave the array in its original state after they finish so that the computation can be properly resumed. Algorithms in this model can also be relevant for saving communication time, in case the data is distributed among several machines and would need to be copied to further machines for execution of the subroutine.
Although the requirement of the restoration is stringent compared to the classicalversions of the problems, this model is more relaxed than a read-only memory where the input elements are not allowed to be moved within the input array. We first show that for a sequence of n integers, selection (finding the median or more generally the k-th smallest element for a given k) can be done in O(n) time using O(lg n) words1 of extra space in this model. In contrast, no linear-time selection algorithm is known that uses polylogarithmic space in the read-only memory model.
For sorting n integers in this model, we first present an O(nlg n)-time algorithm using O(lg n) words of extra space that outputs (in a write only tape) the given sequence in sorted order while restoring the order of the original input in the input tape. When the universe size U is polynomial in n, we give a faster O(n)-time algorithm (analogous to radix sort) that uses O(nε) words of extra space for an arbitrarily small constant ε > 0. More generally, we show how to match the time bound of any word-RAM integer sorting algorithms using O(nε) words of extra space. In sharp contrast, there is an Ω (n2/S)-time lower bound for integer sorting using O(S) bits of space in the read-only memory model. Extension of our results to arbitrary input types beyond integers is not possible: for “indivisible” input elements, we can prove the same Ω (n2/S) lower bound for sorting in our model. We also describe space-efficient algorithms to count the number of inversions in a given sequence in this model.
En route, we develop linear-time in-place algorithms to extract leading bits of the input array and to compress and decompress strings with low entropy; these techniques may be of independent interest.

References

[1]
M. Ajtai. 2002. Determinism versus nondeterminism for linear time RAMs with memory restrictions. Journal of Computational and Systems Sciences 65, 1, 2--37.
[2]
A. Andersson, T. Hagerup, S. Nilsson, and R. Raman. 1998. Sorting in linear time? Journal of Computer and System Sciences 57, 1, 74--93.
[3]
T. Asano, A. Elmasry, and J. Katajainen. 2013. Priority queues and sorting for read-only data. In Proceedings of the 10th International Conference on Theory and Applications of Models of Computation (TAMC’13). 32--41.
[4]
T. Asano, W. Mulzer, G. Rote, and Y. Wang. 2011. Constant-work-space algorithms for geometric problems. Journal of Computational Geometry 2, 1, 46--68.
[5]
P. Beame. 1991. A general sequential time-space tradeoff for finding unique elements. SIAM Journal on Computing 20, 2, 270--277.
[6]
P. Beame, V. Liew, and M. Pǎtraşcu. 2015. Finding the median (obliviously) with bounded space. In Automata, Languages, and Programming. Lecture Notes in Computer Science, Vol. 9134. Springer, 103--115.
[7]
A. Borodin and S. A. Cook. 1982. A time-space tradeoff for sorting on a general sequential model of computation. SIAM Journal on Computing 11, 2, 287--297.
[8]
A. Borodin, M. J. Fischer, D. G. Kirkpatrick, N. A. Lynch, and M. Tompa. 1981. A time-space tradeoff for sorting on non-oblivious machines. Journal of Computer and System Sciences 22, 3, 351--364.
[9]
H. Brönnimann, T. M. Chan, and E. Y. Chen. 2004. Towards in-place geometric algorithms and data structures. In Proceedings of the 20th ACM Symposium on Computational Geometry (SoCG’04). 239--246.
[10]
T. M. Chan. 2010. Comparison-based time-space lower bounds for selection. ACM Transactions on Algorithms 6, 2, 26.
[11]
T. M. Chan and E. Y. Chen. 2007. Multi-pass geometric algorithms. Discrete and Computational Geometry 37, 1, 79--102.
[12]
T. M. Chan and E. Y. Chen. 2010. Optimal in-place and cache-oblivious algorithms for 3-S convex hulls and 2-S segment intersection. Computational Geometry: Theory and Applications 43, 8, 636--646.
[13]
T. M. Chan, J. I. Munro, and V. Raman. 2015. Finding median in read-only memory on integer input. Theoretical Computer Science 583, 51--56.
[14]
T. M. Chan and M. Pǎtraşcu. 2010. Counting inversions, offline orthogonal range counting, and related problems. In Proceedings of the 21st ACM-SIAM Symposium on Discrete Algorithms (SODA’10). 161--173.
[15]
T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. 2009. Introduction to Algorithms (3rd. ed.). MIT Press, Cambridge, MA.
[16]
F. Claude, P. K. Nicholson, and D. Seco. 2011. Space efficient wavelet tree construction. In Proceedings of the 18th International Symposium on String Processing and Information Retrieval (SPIRE’11). 185--196.
[17]
M. Crochemore, R. Grossi, J. Kärkkäinen, and G. M. Landau. 2013. A constant-space comparison-based algorithm for computing the Burrows-Wheeler transform. In Proceedings of the 24th Symposium on Combinatorial Pattern Matching (CPM’13). 74--82.
[18]
A. Elmasry, D. D. Juhl, J. Katajainen, and S. Rao Satti. 2013. Selection from read-only memory with limited work space. In Proceedings of the 17th International Conference on Computing and Combinatorics (COCOON’13). 147--157.
[19]
F. E. Fich, J. I. Munro, and P. V. Poblete. 1995. Permuting in place. SIAM Journal on Computing 24, 2, 266--278.
[20]
G. Franceschini and S. Muthukrishnan. 2007. In-place suffix sorting. In Proceedings of the 34th International Colloquium on Automata, Languages, and Programming (ICALP’07). 533--545.
[21]
G. Franceschini, S. Muthukrishnan, and M. Pǎtraşcu. 2007. Radix sorting with no extra space. In Proceedings of the 15th European Symposium on Algorithms (ESA’07). 194--205.
[22]
G. Frederickson. 1987. Upper bounds for time-space trade-offs in sorting and selection. Journal of Computer and System Sciences 34, 1, 19--26.
[23]
R. Grossi. 2011. Private communication. https://www.imsc.res.in/dsmeet/grossi_dsmeet2011_1.pdf.
[24]
Y. Han. 2004. Deterministic sorting in O(n lg lg n) and linear space. Journal of Algorithms 50, 1, 96--105.
[25]
Y. Han and M. Thorup. 2002. Integer sorting in O(n√lg lg n) expected time and linear space. In Proceedings of the 43rd IEEE Symposium on Foundations of Computer Science (FOCS’02). 135--144.
[26]
J. Katajainen and T. Pasanen. 1992. Stable minimum space partitioning in linear time. BIT Numerical Mathematics 32, 4, 580--585.
[27]
J. Katajainen and T. Pasanen. 1994. Sorting multisets stably in minimum space. Acta Informatica 31, 4, 301--313.
[28]
T. W. Lai and D. Wood. 1988. Implicit selection. In Proceedings of the 1st Scandinavian Workshop on Algorithm Theory (SWAT’88). 14--23.
[29]
J. I. Munro and M. Paterson. 1980. Selection and sorting with limited storage. Theoretical Computer Science 12, 315--323.
[30]
J. I. Munro and V. Raman. 1996. Selection from read-only memory and sorting with optimum data movement. Theoretical Computer Science 165, 2, 311--323.
[31]
J. I. Munro, V. Raman, and J. S. Salowe. 1990. Stable in situ sorting and minimum data movement. BIT Numerical Mathematics 30, 2, 220--234.
[32]
R. Pagh and J. Pagter. 2002. Optimal time-space trade-offs for non-comparison-based sorting. In Proceedings of the 13th ACM--SIAM Symposium on Discrete Algorithms (SODA’02). 9--18.
[33]
J. Pagter and T. Rauhe. 1998. Optimal time-space tradeoffs for sorting. In Proceedings of the 39th IEEE Symposium on Foundations of Computer Science (FOCS’98). 264--268.
[34]
V. Raman and S. Ramnath. 1999. Improved upper bounds for time-space tradeoffs for selection. Nordic Journal of Computing 6, 2, 162--1999.
[35]
G. Tischler. 2011. On wavelet tree construction. In Proceedings of the 22nd Symposium on Combinatorial Pattern Matching (CPM’11). 208--218.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Transactions on Algorithms
ACM Transactions on Algorithms  Volume 14, Issue 2
April 2018
339 pages
ISSN:1549-6325
EISSN:1549-6333
DOI:10.1145/3196491
Issue’s Table of Contents
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 16 April 2018
Accepted: 01 November 2017
Revised: 01 November 2017
Received: 01 December 2016
Published in TALG Volume 14, Issue 2

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Read-only memory
  2. in-place extraction
  3. restore
  4. selection problem
  5. sorting integers

Qualifiers

  • Research-article
  • Research
  • Refereed

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)11
  • Downloads (Last 6 weeks)3
Reflects downloads up to 12 Sep 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Sparse Suffix and LCP Array: Simple, Direct, Small, and FastLATIN 2024: Theoretical Informatics10.1007/978-3-031-55598-5_11(162-177)Online publication date: 6-Mar-2024
  • (2021)Memory-Adjustable Navigation Piles with Applications to Sorting and Convex HullsACM Transactions on Algorithms10.1145/345293817:2(1-19)Online publication date: 6-Jun-2021
  • (2021)Approximation in (Poly-) Logarithmic SpaceAlgorithmica10.1007/s00453-021-00826-7Online publication date: 5-Apr-2021
  • (2020)Re-Pair in Small SpaceAlgorithms10.3390/a1401000514:1(5)Online publication date: 25-Dec-2020
  • (2019)Linear-Time In-Place DFS and BFS on the Word RAMAlgorithms and Complexity10.1007/978-3-030-17402-6_24(286-298)Online publication date: 27-May-2019

View Options

Get Access

Login options

Full Access

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media