On demand string sorting over unbounded alphabets

Carmel Kent, Moshe Lewenstein, Dafna Sheinwald

Research output: Contribution to journalArticlepeer-review

3 Scopus citations


On-demand string sorting is the problem of preprocessing a set of strings to allow subsequent queries for finding the k lexicographically smallest strings (and afterward the next k etc.) This on-demand variant strongly resembles the search engine queries which give you the best k-ranked pages recurringly. We present a data structure that supports this in O(n) preprocessing time, where n is the number of strings, and answer queries in O(logn) time. There is also a cost of O(N) time amortized over all operations, where N is the total length of the strings. Our data structure is a heap of strings, which supports heapify and delete-mins. As it turns out, implementing a full heap with all operations is not that simple. For the sake of completeness, we propose a heap with full operations based on balanced indexing trees that supports the heap operations in optimal times.

Original languageEnglish
Pages (from-to)66-74
Number of pages9
JournalTheoretical Computer Science
StatePublished - 6 Apr 2012

Bibliographical note

Funding Information:
This work was partially supported by the Israel Science Foundation, grant no. 1484/04.


  • Data structures
  • String matching


Dive into the research topics of 'On demand string sorting over unbounded alphabets'. Together they form a unique fingerprint.

Cite this