We study the following rearrangement problem: Given $n$ words, rearrange and concatenate them so that the obtained string is lexicographically smallest (or largest, respectively). We show that this problem reduces to sorting the given words so that their repeating strings are non-decreasing (or non-increasing, respectively), where the repeating string of a word $A$ refers to the infinite string $AAA\ldots$. Moreover, for fixed size alphabet $\Sigma$, we design an $O(L)$ time sorting algorithm of the words (in the mentioned orders), where $L$ denotes the total length of the input words. Hence we obtain an $O(L)$ time algorithm for the rearrangement problem. Finally, we point out that comparing primitive words via comparing their repeating strings leads to a total order, which can further be extended to a total order on the finite words (or all words).
翻译:我们研究了以下重新排列问题:用美元字数、重新排列和混合它们,使获得的字串在字典上最小(或最大,分别最大)。我们表明,这个问题会降低到对给定词的排序,这样它们的重复字符串不会减少(或没有增加),因为一个单词的重复字符串中美元是指无限的字符串$AAA=Aldots美元。此外,对于固定大小的字母字母组,我们设计了一个(上述单词组中的)美元(L)时间排序算法,用美元表示输入词的总长度。因此我们获得了一个用于重新安排问题的O(L)$时间算法。最后,我们指出,通过比较它们的重复字符串来比较原始词组可以导致一个总顺序。 对于限定词组(或所有单词),我们可以进一步扩展到一个总顺序。