简体   繁体   English

如何证明排序网络深度的下界是 lgn?

[英]How to prove that lower bound of a sorting networks depth is lgn?

I'm trying to answer clrs intro to alg edition2 exercises.我正在尝试回答 clrs intro to alg edition2 练习。 in chapter 27.1-4 there is an exercise which says: "Prove that any sorting network on n inputs has depth at least lg n".在第 27.1-4 章中有一个练习说:“证明任何在 n 个输入上的排序网络的深度至少为 lg n”。 so I think that we can use at most (n/2) comparators in each depth and if we assume that we have found a combination of comparators which can sort (n/2) of the numbers in depth1 then we need to sort the other (n/2) of the numbers.所以我认为我们最多可以在每个深度使用 (n/2) 个比较器,如果我们假设我们找到了一个比较器的组合,可以对深度 1 中的 (n/2) 个数字进行排序,那么我们需要对另一个进行排序(n/2) 个数字。 So if we keep doing the same thing we're dividing n by two in each depth so the depth of the sorting network would be lgn.因此,如果我们继续做同样的事情,我们将在每个深度中将 n 除以 2,因此排序网络的深度将为 lgn。 Is this conclusion wrong?这个结论是错误的吗? if it is what is the right way of proving the lower bound of a sorting networks depth.如果这是证明排序网络深度下限的正确方法。

I can think of two.我能想到两个。

The first is that you can view a sorting network for n elements as a comparison-based sorting algorithm, and the lower bound on the latter implies that the network does lg n, = n lg n − n + O(log n) comparisons.第一个是您可以将 n 个元素的排序网络视为基于比较的排序算法,后者的下限意味着网络进行 lg n, = n lg n − n + O(log n) 比较。 divided by n/2 comparisons per level is 2 lg n − 1 + O((log n)/n) ≥ lg n if n ≥ 2 (and you can verify n = 1 manually).每个级别除以 n/2 比较是 2 lg n - 1 + O((log n)/n) ≥ lg n 如果 n ≥ 2(您可以手动验证 n = 1)。

The other is that after r rounds, each input can have been shuffled to at most 2 r different locations.另一个是在 r 回合之后,每个输入最多可以被洗牌到 2 个r不同的位置。 This can be proved by induction.这可以通过归纳来证明。 Each input must be able to reach each output, so 2 r ≥ n, which implies r ≥ lg n.每个输入必须能够到达每个 output,所以 2 个r ≥ n,这意味着 r ≥ lg n。

(Better to ask this kind of question on cs.stackexchange.com in the future.) (以后最好在cs.stackexchange.com上问这种问题。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM