Indeed, to get at that question, the first thing we're going to have to think about is what are we?
事实上,要解决这个问题,我们首先要考虑的是,我们是什么?
It's just not possible to solve some of these problems by hand and this isn't even a domain that's necessarily into the world of CS but speaks to you the applicability of it all.
手工处理这些问题似乎有些不大可能,但这还不是,计算机科学要解决的主要问题,我们的目的只是为了告诉你它的用途。
OK. I know. It looks boring. But it's a structure of the things I want to think about when I go through trying to take a problem and mapping it into a iterative program.
好,我知道这看起来有点无聊,但是这是我要去以迭代的方式,去解决一个问题采取的,措施的大致结构。
We first have to get about the more general question what is it for me to survive period.
我们首先要解决更综合的问题,我阶段性不死意味着什么。
Now, I want to do one concrete problem where you will see how to use these derivatives.
现在我要解决一个具体的问题,从中你会明白如何运用这些导数
So that's the topic that I'd like to address today.
这就是我今天要解决的问题。
These are the problems of insurance that we have to deal with.
这些都是我们要解决的问题
So, the problem we have to solve to help people like MikeIs to find ways to cause those parts of cortex to develop properly when they are children or have them re-learn as adults.
因此,我们要帮助像迈克这样的人解决的问题,就是找到他们在儿童时期使,这些皮层进行发展,或者成年以后再学习的方法。
The strategy then often is to figure out how, what sort of program can solve these problems and then we go on to ask, "How could this program be instantiated in the physical brain?"
心理学家们通常要先弄清,什么样的程序可以解决这些问题,然后我们会接着问到,"这个程序在我们的生理大脑中,是如何进行编译的"
This solves a major problem which I'm going to talk about just at the beginning of class here in a slide or two, is how to get DNA into cells?
这解决了我要讲到的一个主要问题,就是在这节开始的一两张幻灯片中要讲的,怎样将DNA导入细胞的问题
Because if b was odd, then b minus one is even which means on the next step, I can cut the problem in half again.
这意味着我在下一步里解决的问题,规模要小了一半,好,课堂材料的第三题。
That's why there's a lot of emphasis on sharpening your teeth by doing this class of problems.
这就是为什么强调要通过解决这些问题,来提高你的能力
We're going to do the same thing here, we're going to chart out a little bit of what should go into actually making this thing work.
我们要去画一个小小的流程图,来指导问题的解决,那么这里是一个很简单的。
It doesn't do anything but at least that's one bite out of this problem.
虽然这个没起到任何实质性的作用,但是我们朝着我们要解决的问题迈出了一小步。
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的时候停止分解,那是一个非常简单的对比。
So no harm is done, once we've clarified the question that we're trying to ask, if we summarize that question in a bit of a jargon or slogan.
其实没什么的,一但我们证实了我们,试图想要解决的问题,如果把这个问题用术语或行话简化
These are going to be fairly common-sense definitions, but they're important, and when you get to a problem set, really nailing down what the system is, not more, nor less, in terms of the amount of stuff, that's part of the system, it's going to be often very crucial.
这些是,很常识性的定义,但是很重要,当你要解决问题时,务必要搞清楚系统是什么,它包含多少物质,不能多也不能少,这往往,是非常重要的。
Again, same kind of reasoning says, given some value x, I happened to pick a small one here, what's an easy way to do this? Well, let's just start at one. That's my variable I'm going to change and check.
好,尤其是,让我们到这里来,让我给大家看看第二个例子,让我把这个注释掉,这是我要解决的,第二个问题,假设我想找到一些整数的,所有除数,我想要找出来这个数的所有的除数。
That doesn't solve the problem we had before though Then I'm going to append it, and keep the last change for future use.
这样没有解决我们之前的问题,所以我要给它加上一个值,让上一次的变化能够用到未来的例子中。
So if I try to apply the same logic, well how can I divide and conquer this problem.
如果我想要用同样的逻辑,那么怎样划分,并解决这个问题呢?
So if I were to solve this problem, here's the way I would do it. I would say, first thing I want to do, is I want to input a value for the base as a float.
如果我想要解决这个问题,这就是我要解决它的方式了,第一件我要做的事情就是要,输入一个浮点数作为三角形的底。
Then, here is what we actually do.
然后,这就是我们真正要解决的问题
Well, realize one of the themes in this course and really one of the themes in programming and solving any problem with a machine is going to be really to just take small bites one at a time out of these problems until the end result ultimately is that you've actually bitten off a fairly large fairly interesting problem and in the aggregate, you've actually implemented something pretty sophisticated.
好吧,让我们先想一下这件事带给我们的主题,编程和解决问题的思想,一台机器最开始只会一步一个脚印,沿着要解决的问题向前迈进,直到最终的结果出来,最后你会发现,你已经解决了一个相当大,相当有趣的问题,而这个问题在最初看起来确是相当复杂的。
t In the b even case, again I'm going to let t of b be the number of steps I want to go through.
如果b为偶数,那么我还是要用,来代表解决这个问题需要的步骤数。
The algorithm on mine professed to be implementing now is this thing.
这个算法现在要,解决的就是这个问题。
That's the question we're going to try and address. If we can do this, this is good, because first of all, it removes any questions about what machine I'm running on, it's talking about fundamentally, how hard is this problem, and the second thing is, it is going to do it specifically in terms of the input. Which is one of the things that I was worried about.
这是一个我们接下来要去,尝试和解决的问题,如果我们能做到的话会很不错,因为首先,它解决了结果可能和我,运行的计算机有关系的问题,因为这从根本了告诉了,我们这个问题的复杂度,第二件事情,就是这种方法可以依据输入的大小来计算,而这正是我最担心的地方。
Typically up till now, we've looked at things that can be done in sublinear time. Or, at worst, polynomial time. We'll now look at a problem that does not fall into that. And we'll start with what's called the continuous knapsack problem.
至今为止我们已经处理过,亚线性问题,最多也就是多项式问题,我们现在要看的问题则是不能用这些解决的,我们将要开始讲连续背包问题。
That gets us to the smart thief. Why is this thief smart? Because she took 600. And she learned 600 that in fact there is a good way to solve this problem. And that's what we're going to talk about next. And that's something called dynamic programming.
现在我们要当聪明的贼,这个贼为什么聪明呢?,因为它选择了,它知道这事实上是解决这个问题的好方法,这就是我们接下来要讲的,也就是动态编程。
Scheme And I happen to like Lisp and Scheme, it's a great language when you're trying to deal with problems where you have arbitrarily structured data sets.
而且我很偶然的喜欢上了Lisp和,这些是当你要试图解决你,曾经很武断的设置数据,的地方的问题时很棒的语言。
应用推荐