Patience Sort sorts a sequence of numbers with a minimal number of queues that work according to the First-In-First-Out (FIFO) principle. More precisely, if the length of the longest descreasing subsequence of the input sequence is $L$, then Patience Sort uses $L$ queues. We ask how much one can improve order with $k$ queues, where $k < L$? We address this question for two measures of sortedness: number of down-steps and length of the longest descreasing subsequence. For the first measure, we give an optimal algorithm. For the second measure, we give an algorithm that reduces the LDS from $L$ to $L - k + 1$, and we provide a sequence with LDS $L$ that can't be reduced to an LDS lower than $L - k + 1$ with $k$ queues. Moreover, we study the mergeability of two sequences of numbers, providing an optimal linear algorithm for two queues with LDS $\leq 2$. The research was inspired by a problem arising in car manufacturing.
翻译:耐心排序法利用遵循先进先出(FIFO)原则的最小队列数对数字序列进行排序。更精确地,若输入序列的最长递减子序列长度为 $L$,则耐心排序法使用 $L$ 个队列。我们探究当 $k < L$ 时,使用 $k$ 个队列能在多大程度上改善有序度?针对两种有序度度量指标——下降步数与最长递减子序列长度,我们研究该问题。对于第一种度量,我们给出最优算法;对于第二种度量,我们提出一种能将最长递减子序列从 $L$ 缩减至 $L - k + 1$ 的算法,并给出一个无法通过 $k$ 个队列将最长递减子序列降至低于 $L - k + 1$ 的 $L$ 长度序列。此外,我们研究两个数字序列的可合并性,针对最长递减子序列 $\leq 2$ 的两队列场景,给出最优线性算法。该研究受汽车制造业实际问题启发。