谁能给我解释一下这句话?
The sorting algorithm is a modified mergesort (in which the merge is omitted if the highest element in the low sublist is less than the lowest element in the high sublist).
我知道 Merge 是如何工作的,但我还是不太了解。 谢谢。
最佳答案
Mergesort 递归地合并已排序的子列表。如果当前符合合并条件的子列表不包含重叠元素,则无需合并它们。将跳过合并操作。
例子:
List A
1 4 8 9
List B
10 12 14 19
不需要比较这些列表的过程,因为 9 是 A 的最大元素,而 10(B 的第一个元素)大于 A 的最大元素。结果只是 A 的串联和 B.
所有文件都在说,如果不需要综合处理,他们会走捷径。
关于Java排序算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4249794/