This article introduces a new optimization method to improve mergesort's runtime complexity, when sorting sequences that have equal keys to $O(n log_2 k)$, where $k$ is the number of distinct keys in the sequence. When $k$ is constant, it is evident that mergesort is capable of achieving linear time by utilizing linked lists as its underlying data structure. Mergesort linked list implementations can be optimized by introducing a new mechanism to group elements with equal keys together, thus allowing merge algorithm to achieve linear time.
翻译:本条引入了一种新的优化方法, 以改善合并的运行时间复杂性, 当排序键等于$O(n log_ 2 k) 的序列时, 美元是序列中不同键的数量。 当 $K$ 不变时, 合并的状态显然能够通过使用链接列表作为其基本数据结构实现线性时间。 合并的状态链接列表的实施可以通过引入将等键元素组合在一起的新机制得到优化, 从而允许合并算法实现线性时间 。