Perhaps more importantly, how to recognize a kind of algorithm based on its properties and know what class it belongs to. This is a hint. If you like, leaning towards the next quiz, that you oughta be able to say that looks like a logarithmic algorithm because it's got a particular property. That looks like an n log n algorithm because it has a particular property.
也许更重要的是,如何根据一个算法的特点将其辨别出来,并且知道它属于哪一类算法,这是一个提示,就对于接下来的测验来说,如果你喜欢你可以说它看起来像一个对数算法,因为它有一个特定的性质,那个看起来像一个n,log,n的算法,因为它有一个特定的性质。
and we like log algorithms, because they're really fast. A typical characteristic of a log algorithm is a pro-- or sorry, an algorithm where it reduces the size of the problem by a constant factor.
并且我们也很喜欢对数算法,因为它很快,对数算法的典型特性是高速,哦,抱歉,是他能以常数因子的速度,降低问题的大小,很明显。
And what does N log N feel like vis-a-vis N squared?
同N平方相比,N*log,N又是怎样的呢?
With this, if I can assume that accessing the i'th element of a list is constant, then you can't see that the rest of that analysis looks just like the log analysis I did before, and each step, no matter which branch I'm taking, I'm cutting the problem down in half.
读取数组中的第i个元素,是个常量时间的操作的话,我也就能像以前那样得到,这个算法是对数级复杂度的分析,并且每一步不管我选择哪个区间,我都可以把问题的规模缩小一半。
应用推荐