So this is a nice little search-- sorry, a nice little sort algorithm . And in fact, it's relying on something that we're going to come back to, called the loop invariant.
恩,这是一个很棒的小搜索,抱歉,和很棒的小排序算法,事实上,它依赖于一些我们要回顾的东西,被称作循环不变量。
Well, we saw the teaser in terms of that animation that suggests this merge sort algorithm when implemented by a computer is absolutely faster.
我们从前面的动画中可以看到,这个归并排序算法在计算机上实现之后,绝对比其他算法更快。
Where those pieces, I would do the same thing with, I would divide them up into smaller chunks, and sort those. Is that going to give me a more efficient algorithm?
合并起来,而那些小列表,我又会把他们拆成更小的列表,再排序,这会给我,一个更高效的算法么?
And so the fact that in this whole slide here, this algorithm for sorting, I'm using the verb sort.
在这个排序算法中,我用到了一个动词排序。
They are computationally challenged, meaning, at the time they were invented, they were perfectly good sorting algorithms, there are better ones, we're going to see a much better one next time around, but this is a good way to just start thinking about how to do the algorithm, or how to do the sort.
他们是相当棒的排序算法,是有更好的算法,我们下一次,就会看一个更好的,但是开始想想,如何完成算法,或者说是如何排序,是一个好的学习方法,恩,再试试吧,如何来排序呢?
N But it's definitely not one and in fact it wasn't N in the case of Selection Sort because remember the algorithm we implemented on stage last week had me going back and forth across the stage selecting on iteration, the smallest person I can find, the smallest number and then putting them into place.
但在选择排序中,肯定不会是1,也不是,注意,上周我们在这儿,实现的算法中,反复地,迭代进行选择,选出最小的数,然后将其放在合适的位置。
If I'm using algorithm that I'm now calling merge sort, T the running time involved in sorting N elements, T of N, you know, is just the same as running the algorithm for the right half, plus what's this plus N come from?
如果我用归并排序算法,对N个元素其运行时间,就等于此算法一半元素的运行时间,另一半的运行时间,再加上N,这个N是什么呢?
应用推荐