It literally halves the amount of time it takes to solve that problem but we can actually do better.
它能把解决问题时间的缩短一半,但其实我们能做的更好。
You do owe her a meal after she solved your attire problem after all.
她把你的外貌问题给解决了,你确实得请她吃一顿饭。
We just go through the list top to bottom, left to right, and cross names off as we go.
我们会从上到下,从左到右看那个问题清单,如果解决了就把名字擦掉。
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.
好,尤其是,让我们到这里来,让我给大家看看第二个例子,让我把这个注释掉,这是我要解决的,第二个问题,假设我想找到一些整数的,所有除数,我想要找出来这个数的所有的除数。
Define the path. Get all of these really clear, and you've basically solved the problem.
把所有这些搞清楚,你就基本上解决这个问题了。
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.
其实没什么的,一但我们证实了我们,试图想要解决的问题,如果把这个问题用术语或行话简化
We'll see why they have to separate that in a minute, but they do that these lipid bi-layers solve that problem for them and they're self-assembled structures from these molecules called phospholipids.
我们马上会讲到为什么要把它们隔离开,脂质双层膜解决了这个问题,而这些自主装结构,就是由磷脂分子组成的
So we've got a chord progression.
现在我们把和弦进行的问题解决了。
OK. Binary search is perhaps the simplest of the divide and conquer algorithms, and what does that mean? It says, in order to solve a problem, cut it down to a smaller problem and try and solve that one.
好了,二分搜索也许是,最简单的分治算法,这意味着什么?,也就是说,为了解决一个问题,把它切割成小的问题,然后再来一个个解决。
OK. So, what do I want you to take away from this? This idea of binary search is going to be a really powerful tool. And it has this property again, of chopping things into pieces.
从这里学到些什么?二分查找的思想,是一个非常有用的工具,我重复一遍,把问题拆成几部分来解决,那事实上,这里的增长率是多少?
Right, so the things we want you to take away from this are, get into the habit of using pseudo code when you sit down to start a problem, write out what are the steps.
好,这儿我想大家明白的就是,养成解决问题时先写伪代码的好习惯,把步骤都写出来,我想要告诉你们的是一个好的程序员。
And so frequently what we try and do is, we take a new problem and map it onto an old problem so that we can use an old solution.
我们经常做的一件事就是,我们处理一个新问题时,把它归结为一个老问题,以便我们能采取老的解决方式。
So this is very similar, this is a kind of recursive thinking we talked about earlier, where we take our problem and we make it smaller we solve a smaller problem, et cetera.
我们则跳过比猜想数小的那个区间,然后我们重复这一过程,跟之前我们讲过的,递归思想非常类似,我们解决问题的时候,先把问题一步步变小,然后解决小问题。
Delete those lines of code and move them up to the top and problem solved.
把这几行代码删除,然后把它们放到,前面去,问题就解决了。
You can take a problem that might be relatively intuitive to solve but when you scale this thing up as is increasingly the case in the web, in large data systems, and so forth, you actually have to now think smart, you actually have to think efficiently and you have to solve this problem effectively.
你可以把一个问题用比较直观的方法解决,但如果你把此类问题的数量增大,正如越来越多的互联网,和大规模数据系统中出现的问题等等,你应该考虑怎样才能更简便,怎样才能更高效,你应该用行之有效的方法处理问题。
So yes, f is a float, but that solution is too late; we need to fix the problem sooner.
是的,f是一个浮点数,但是那个解决方案太迟了;,我们应该在次之前把问题解决。
应用推荐