gpt4 book ai didi

sorting - "partially sorted"的数学定义

转载 作者:行者123 更新时间:2023-12-02 20:48:31 29 4
gpt4 key购买 nike

例如,插入排序被描述为部分排序数组的有效算法。但如何精确定义“部分排序”呢?

最佳答案

这是一个只有少数元素不合适的数组。如果没有指定百分比或其他阈值,则部分排序和未排序之间没有严格的区别。

正式定义来自Algorithms作者:罗伯特·塞奇威克和凯文·韦恩:

More generally, we consider the concept of a partially sorted array, as follows: An inversion is a pair of entries that are out of order in the array. For instance, E X A M P L E has 11 inversions: E-A, X-A, X-M, X-P, X-L, X-E, M-L, M-E, P-L, P-E, and L-E. If the number of inversions in an array is less than a constant multiple of the array size, we say that the array is partially sorted.

Insertion sort 的维基百科页面表述如下:

[...] the array A will be partially sorted in the sense that each element is at most K positions away from its final, sorted position. [...]

关于sorting - "partially sorted"的数学定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29341479/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com