对,那是正确的。看到这一点的一种方法是通过对抗性论证。假设您有一个算法,据称可以找到数组中的最大值,但不会至少检查每个数组元素一次。
Suppose I run your algorithm on some array A1 that consists of nothing but the number 0. Since your algorithm doesn't look at all positions in the array, there's some position it doesn't look at; call that position k. Now, define A2 to be an array that's the same as array A1, except that the element at position k in A2 is defined to be 1.
Now, what happens if I run your algorithm on A2? Since your algorithm never looked at position k in A1 and A2 is identical to A2 except at position k, your algorithm can't tell A1 and A2 apart. Therefore, whatever it says for A1 must be the same as what it says for A2.
That's a problem, though. If your algorithm says that the maximum value is 0, then it's wrong for A2, whose max is 1. If your algorithm says that the maximum value is 1, then it's wrong for A1, whose max is 0. Therefore, the algorithm has to be wrong in at least one case, so it can't be a correct algorithm for finding the maximum value.
该参数表明,任何始终找到数组中最大值的确定性算法都必须查看该数组中的所有位置,因此运行时间必须为 Ω(n) 才正确。
希望这可以帮助!