Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update C2.人间大炮一级准备.md #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion C2.人间大炮一级准备.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@

平均来说是n/2,根据概率来说是一半的可能性在前一半就找到了。

#平均应该是n+1/2,n个元素都有1/n的可能是要查找的元素,则检查1个元素、2个元素...n个元素的概率都是1/n,平均就是1*1/n+2*1/n+3*1/n+...+n*1/n=(1+n)/2

最差的情况是n。

不管哪种都是Θ(n)。
Expand Down Expand Up @@ -493,4 +495,4 @@ OK!Done!

我想,原因一是归并排序削去了插入排序中多余的**比较部分**Θ(n^2),只留下了最小的**比较+移动部分**Θ(nlgn)。

原因二,就是在这个例子中,最聪明的一步是**转化了问题**,把一个寻找数量的问题化为一个排序的问题,可以说是神来之笔,我的脑子还远远不能到达这个地步,可敬可叹!
原因二,就是在这个例子中,最聪明的一步是**转化了问题**,把一个寻找数量的问题化为一个排序的问题,可以说是神来之笔,我的脑子还远远不能到达这个地步,可敬可叹!