合并k排序的大小为n的阵列少于o(nklogk)时间复杂性

发布于 2025-01-31 01:11:12 字数 845 浏览 3 评论 0 原文

问题:

合并k排序的阵列每个元素在最小的时间复杂性下将n元素带入一个大小NK的单个数组。该算法应是基于比较的算法。

不应在输入上进行假设。

因此,我知道在此处提到的nklogk时间复杂性解决问题的算法:

但是,我的问题是我们可以在少于 nklogk 中排序,意思是,运行时为 o(nklogk)

因此,我通过互联网搜索并找到了这个答案: Merge k in o(o(o) NK)时间复杂性

声称将大小K的数组分为单例,然后将它们合并为单个数组。但这是不正确的,因为人们可以声称他找到了一种算法,该算法可以在 sqrt(n)klogk 中解决该问题,该算法是 o(nklogk) n = 1 因此,我们对 klogk 时间的数组进行排序,该数组与对数组的排序不矛盾。

那么,我该如何与分类数组的下限相抵触呢?含义,对于一个大小为n的数组,在输入上没有任何假设,排序至少需要NLOGN操作。

The question:

Merge k sorted arrays each with n elements into a single array of size nk in minimum time complexity. The algorithm should be a comparison-based algorithm. No assumption on the input should be made.

So I know about an algorithm that solves the problem in nklogk time complexity as mentioned here: https://www.geeksforgeeks.org/merge-k-sorted-arrays/.

Though, my question is can we sort in less than nklogk, meaning, the runtime is o(nklogk).

So I searched through the internet and found this answer:
Merge k sorted arrays of size n in O(nk) time complexity

Which claims to divide an array of size K into singletons and merge them into a single array. But this is incorrect since one can claim that he found an algorithm that solves the problem in sqrt(n)klogk which is o(nklogk) but n=1 so we sort the array in KlogK time which doesn't contradict the lower bound on sorting an array.

So how can I contradict the lower bound on sorting an array? meaning, for an array of size N which doesn't have any assumptions on the input, sorting will take at least NlogN operations.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2025-02-07 01:11:12

n log n 的下限仅适用于基于比较的排序算法(堆排序,合并排序等)。当然,有一些分类算法具有更好的时间复杂性(例如计数排序)但是,它们不是基于比较的。

The lower bound of n log n only applies to comparison-based sorting algorithms (heap sort, merge sort, etc.). There are, of course, sorting algorithms that have better time complexities (such as counting sort), however they are not comparison-based.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文