Whereas in the linear case, I make it ten times bigger, it takes ten times longer to run. OK.
它要占用原来十倍的时间去运行,我一直在说还有一件事情没有讲,这是我要强调的最后一件事。
It could run and give you the right answer, it could crash, it could loop forever, it could run and apparently give you the right answer.
它可能会正确运行,并返回给你一个正确的答案,它可能会崩溃,它可能会一直运行下去,它可能会运行并给你正确的答案。
If you've ever been using some program, you did something completely innocuous, pull something down from a menu, click a button, you didn't do anything wrong and yet all of a sudden the thing just starts hanging there or you get a little spinning beach ball or the hour glass or whatever it is.
如果你之前在用一些程序,做一些无伤大雅的事情,拉下一个菜单,点击一个按钮,你没有做任何错误的事情,突然间有东西开始一直运行,或者一个沙滩上的小球旋转,或滴漏或是别的什么。
It will probably quit at some point because of space issues, unless I'm writing an algorithm that is using no additional space.
其中一个的时候,它会一直运行下去,它可能在某一处因为空间问题退出,除非我写了一个。
What I don't want your program to do is crash when that happens. Or run forever.
当这种问题出现时程序崩溃,或者一直运行下去。
STUDENT: Yeah. It'll go forever. Absolutely, right?
学生:不可闻的声音:,程序会一直运行下去,绝对是?
All right? A linear search, I start at the beginning of the list and walk all the way through it. All right, if I'm lucky and it's at the low end, If it's not, if it's at the far end, I've got to go forever, and you saw that last time where this thing paused for a little while while it actually searched a list this big.
如果很幸运就在开头,那运行起来很快,如果是在末尾,那就一直得走到头,上次看到了,如果搜索空间很大,程序都会暂停一会,好的,那我希望你们。
应用推荐