Whereas in the linear case, I make it ten times bigger, it takes ten times longer to run. OK.
它要占用原来十倍的时间去运行,我一直在说还有一件事情没有讲,这是我要强调的最后一件事。
Therefore, for simple branching programs, the length of time, the complexity the code, is what we would call constant.
因此,对于简单的分支程序,运行的时间长度,算法的复杂度,也就是我们说的常数。
And two, to give you a better sense of design especially as your programs get a little more involved and they play or they run for more than just a few seconds time.
另一方面,使你们对设计更有感觉,尤其是你的程序要适用于更多的应用环境或,要运行不止几秒钟时间的时候。
In our business, you got to be inventing new things because software doesn't wear out, it doesn't break, or at least if it breaks it was broken when you finished it, it doesn't break over time the way physical goods do.
在我们行业,你需要不断发明新事物,因为软件并不会磨损,不会坏,或者至少如果坏了,也是在你运行完之后,它并不像物理上的东西会随着时间磨损。
I sort of blocked it out with the circles, but then you can go put in two servings, and you put what time of day you had it and then the program will be able to do its work.
我把它圈了出来,你输入说是两份,之后输入进食的时间,系统随后就能运行分析
Over all possible inputs to this function, what's the fastest it runs? The fewest, so the minimum, if you like.
哪个输入程序运行的最快?,用的时间最少?如果你喜欢的话,这个方法看起来不错。
Said a different way, in the case of the straight-line programs, how long would it take to run a program?
换种说法,在直线式程序里面,运行一个程序要多长时间?
One of the things you could imagine is just try it on and input, see how long it takes.
你们想出来的方法只是可能就是通过,输入来试试,看运行时间会有多长。
So how long it takes to run is related to how many items I end up being able to fit into the knapsack.
所以,运行的时间是和我能够,装进背包的物品数目有关的。
But you don't want to have to run it a long time, every time you have a hypothesis.
但是你不必每次有一个假设,都要去运行很长时间。
And so you care-- you care about ultimately how much time is my algorithm gonna take to perform on that worst case running time.
因此你最终所关心的是,算法在最坏情况下需要多长的,运行时间。
I ask you for the running time of this algorithm and you give me the running time in terms of the running time, right.
我需要得到此算法的时间复杂度,那就明确地给出其,运行时间。
And this was just a formal way of describing the best case running time and in the case of Selection Sort, what was the best case running time?
这是描述最好情况下运行时间的,一种正式的方式,在选择排序中,最理想的运行时间是多少呢?
All right? If you run it, you have a sense of the upper bound, about how much time it's going to take to do this computation, so you're not going to get surprised by something showing up.
第一,这样做意味着没有意外了对不对?,你去运行程序,你已经大致知道运行时间的上限了,因此发生任何事情,你都不会吃惊了。
In fact, if I ran one of these things, it would just keep crunching away.
我们主要来谈谈时间问题,实际上,让我运行这些东西。
What I want to think about though, is, how much time does this take?
我想的是,这个程序需要多长的时间来运行?
One of the inputs to the problems we're gonna be working on this semester and if you continue on in this world how much thought it takes to implement something, how much time it takes to run something, how much space it takes to run something?
我们将在本学期集中探讨这些问题,或者在课程之后你们也可以继续研究,为实现一些功能要有多少想法,在运行过程中又将花费多长时间,需要多大的空间?
Times were different in those days.
程序运行了很长时间然后停止了。
And so very often I would find myself with gigabytes worth of data, at night I needed to analyze this data and look for this patterns and frankly the reality was sometimes I could spend 10-15 minutes whipping up a little script, a little program that unfortunately would take eight hours or more to run.
我经常会发现十亿字节的数据,晚上我就需要分析这些数据并,找出模型,坦白说,有时,我会花10-15分钟来编写一个小脚本,一个小程序,但不幸的是,运行它可能需要8个小时或更多时间。
And yet get a valid test. Sometimes it can be timing. If you're running multiple processes.
有些时候当你运行多线程时,是因为时间的原因。
If there's no work to be done, 0 the running time is gonna be zero.
如果并不需要做什么,那么其运行时间肯定为。
Does it give you the answer that you expected it to give? Often, in practical problems, you'll spend just as much time doing performance debugging. Why is it slow?
它返回了期待中的结果了么?通常,在实际的问题中你会花,同样多的时间在性能调试上,它为什么运行这么慢?
But here I want it to be determined, chosen at run time.
但是在这里我想要让它是一个由运行时间。
Remember last time, I said that there's different kinds of complexity in our code, and I suggested for simple branching programs, the amount of time it takes to run that program is, in essence, bounded by the number of instructions, because you only execute each instruction at most once.
但是这里有个很重要的点,记得上节课,我提过在我们的代码中,有不同种类的复杂度,而且我还说了对于简单的分支程序,运行这种程序需要的总体时间,大体上,是和指令的数目相关的,因为每个指令只会被执行最多一次。
So the running time of the problem where the input is T of size N as expressed here formulaically, T of N, the running time of an algorithm, given an input of size N. You know what?
因此一个输入为N的问题的运行时间,在这儿的公式表示为,如果输入为N,那么此算法的运行时间,是多少呢?
In general, when we wanna talk about running time, we just need a silly place holder, so we'll call it T for time.
一般情况下,当我们讨论运行时间时,需要一种表示方法,这里T表示时间。
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是什么呢?
应用推荐