Simple linear time algorithm for sorting strings in omega-order with applications
Published in Acta Informatica, 2026
We present a simple linear time algorithm for the following sorting problem: Given \(n\) words \(A_1,\ldots,A_n\), find a permutation \(\{\pi_1,\ldots,\pi_n\}\) of \(1,\ldots,n\) so that \((A_{\pi_1})^\omega\leq\ldots\leq(A_{\pi_n})^\omega\), where \((A)^\omega\) denotes the infinitely repeating string \(AAA\ldots\). Let \(L\) denote the total length of the given strings. We note that the running time of our algorithm is \(O(L)\) even if the size of alphabet is beyond \(O(1)\). We also present an \(O(L+n \log n)\) time algorithm for the restricted model where we are only allowed to compare symbols. In other words, the main result of this paper is that the time complexity of sorting (in lexicographic order) is the same as that of sorting (in \(\omega\) order) under all common models (bounded alphabet, unbounded alphabet, compare-based model). Our main results find applications in related problems such as rearranging and concatenating given words so that the result is lexicographically smallest or largest.
Recommended citation: Luo, R., Zhu, T. & Jin, K. Simple linear time algorithm for sorting strings in omega-order with applications. Acta Informatica 63, 17 (2026). https://doi.org/10.1007/s00236-026-00530-5
Download Paper | Download Bibtex
