the abuse is, you know, it's not quite right, it depends upon whether it's all ready, but you can see in either case, after 12 steps, 2 runs through this and down to a problem size b over 2.
在12步以后,两轮过后,这个问题的范围b被缩小了一倍,这为什么很不错呢?,这意味着再来12步。
I first had a list of size 8, then 4, then 2, but then I had another problem of size 2.
首先是一个有8个元素的序列,接着变成了4个元素,接着2个元素,然后我就碰到了有2个元素的另一个问题。
Well, that then says after another 12 steps, 12+12+t we're down to a problem with size t of b over 4.
更进一步,也就是。
OK. And then the exponentials, as you saw is when typically I reduce the problem of one size into two or more sub-problems of a smaller size.
好,然后说到指数级,正如你所见,典型的例子是,我讲一个问题分解成为,两个更小规模的子问题。
Now. You might look at that and say, well that's just a lot like what we had over here Right? We had some additive constant plus a simpler version of the same problem reduced in size by 1.
现在你可能会看着这个说,这很像我们以前做过的,对不对?我们用一些附加的常量,加上问题的另外一个规模缩小了1的,简化版本来代替这个问题本身。
Here's the left half, so now I have a problem of size 4.
这边是左半部分,所以现在问题的大小是。
A log algorithm typically is one where you cut the size of the problem down by some multiplicative factor.
对数级复杂度的算法就是指,通过一系列常量级步数的操作,可以将问题的规模。
How do I reduce this to a smaller-size problem in the same instant?
我怎么能把这个问题,缩小成更小规模的问题呢?
We took the problem of size a thousand, we divided it in half.
当我们遇到一个规模为一千左右的问题时,会将其分为两部分。
The second question I want to ask is what's the base case? When do I get down to a problem that's small enough that it's basically trivial to solve? Here it was lists of size one. I could have stopped at lists of size two right. That's an easy comparison.
第二个问题是什么是基础条件?,我要将问题分解到何时才使得问题,小到可以解决的基本问题?,这里是当列表的长度为1有时候,我也可以在长度为2的时候停止分解,那是一个非常简单的对比。
Typical characterization, not all the time, but typical characterization, is an algorithm that reduces the size of a problem by one, or by some constant amount each time, is typically an example of a linear algorithm.
我们学习过了线性算法,它的典型特征,不是通用的,但是比较典型的特征是,它是逐一减小问题的大小的,或者说是每次减小常数的大小。
Taking the problem, recognizing that you know what, 8 even though this is a pretty big problem size 8 in this case and last time it was size 8 or in the case of the papers in size of a thousand roughly with the phonebook, I assume these are in a perfectly straight line they won't quite fit.
以这个问题为例,你们要认识到,在这种情况下,这是个比较大的问题,其大小是,上次它的大小也是8,但在纸片那个问题中,电话簿的规模大概是上千的,现在假设这些,杯子完全在同一条直线上,虽然并不十分符合这个条件。
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.
并且我们也很喜欢对数算法,因为它很快,对数算法的典型特性是高速,哦,抱歉,是他能以常数因子的速度,降低问题的大小,很明显。
If I'm running at nanosecond speed, 1000 n, the size of the problem, whatever it is, is 1000, and I've got a log algorithm, it takes 10 nanoseconds to complete.
如果这个问题的规模,也就是n,是,如果这个问题是对数级的,这将会占据10纳秒的时间,你一眨眼的时间。
I've got one test, I've got a subtraction, I've got a multiplication, that's three steps, plus whatever number of steps it takes to solve a problem of size b minus 1.
我进行了一次比较,一次减法,一次乘法,一共是三个步骤,再加上t的步骤数。
Where you go from problem of size n to a problem of size n minus 1.
或者缩减了2,这都一样的,也就是把问题的规模从n变成了n-1。
And now I have a problem of size N minus 1.
现在是一个N-1大小的问题。
应用推荐