• You'll also notice that this thing goes through the entire list, even if the list is sorted before it gets partway through.

    你也能注意到,它始终会遍历列表,甚至列表在排序之前,就是有序的也是这样。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And because, as long as this collection is finite, this thing is just going to walk through. All right?

    这个操作就会遍历完它的,对不对?,那么,如果我给大家看看,例如?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I just go down the list selecting the smallest person at a time and then I repeat, repeat, repeat but when we actually did out the math or kind of reason through it, the running time, the asymptotic running time of bub-- of Selection Sort was also what?

    只需要遍历列表,每次找出最小的元素,然后重复上述步骤,但从数学角度看,选择排序的时间复杂度,又是多少呢?

    哈佛公开课 - 计算机科学课程节选

  • In other words it doesn't just return when it finds one, it's going to run through all of them. All right?

    但是它将会继续运行,换句话来说当它找到一个结果时,它不会立刻返回结果它会先遍历所有的内容?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • OK? So you can see that, it's just walking through it, and in fact if I look at a couple of another-- another couple of examples, it's been a long day, again, you can see that property.

    恩,其实你能看到,他就是遍历列表,你要有空的话,可以再看很多很多其他的例子,你能够看到这个属性。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • google Imagine you want to search through Google to find a particular page. You want to do it in a second. And you're going to just do it the brute force way, assuming you could even reach all of those pages in that time.

    假设你想通过,搜索一个特定的网页,你想在1秒内得到结果,然后你就只管去做了,认为能在1秒内遍历所有的网页。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • In the second case, I found in the next smallest element and moved here, taking what was there and moving it on, in this case I would swap the 4 and the 8, and in next case I wouldn't have to do anything.

    在第二次遍历中,我找到了,第二小的元素,把它移到这里,把这里原来的元素移到哪里,在这一次遍历中,我会把8和4交换,然后一次遍历,不会做任何事情。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • If it's there, I'm done, if not, I keep walking down, and I only stop when I get to a place where the element I'm looking for is smaller than the value in the list., in which case I know the rest of this is too big and I can stop.

    并且保持遍历,我只在当当前位置的数组元素,大于目标数时停止,这意味着剩下的元素都比目标元素大,但是其他的情况,我还是要遍历完整个数组。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Well basically, all I'd have to do is go through and find every place I checked the constraint, and change it. To incorporate the new constraint.

    比较简单,在最上方,基本上,我做的所有事情就是遍历,整段代码然后找到我对比。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • The better way to think about this is, suppose, rather than starting at the beginning, I just grabbed some spot at random, like this one.

    不从数组的头开始遍历,我随即的从数组中抓一个元素,比如这个,我去看看这个元素的值。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Now you might say, wait a minute. Thing's ordered, if I stop part way through and I throw away half the list, doesn't that help me? And the answer is yes, but it doesn't change the complexity.

    如果我在半路上停下来,然后不去遍历剩下的数组了,这会有帮助么?答案是有帮助,但这没法改变算法的复杂度,因为我们之前怎么说来着?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So what would I want to do? I'd like to somehow walk down each of the digits one at a time and add them up. Ah, that's a looping mechanism, right? I need to have some way of walking through them.

    去取这个数的,每个数字然后把他们加起来,啊,这是个循环机制对不对?,我得找到一个遍历它们的方法,一种简单的方法可能。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I'm walking along the list once, taking two things and saying, make sure the biggest one is next.

    遍历一次列表,每次取两个值,确认最大的元素在后面一个。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Suppose I want to find all the divisors of some integer, I want to figure out what all the divisors are that go evenly into it.

    也就是遍历所有的整数来寻找,一个数的平方根,让我们再来看一个例子吧,为了找出另外一种的解决方法。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So in the first case, I didn't have to do any swaps because 1 was the smallest thing.

    所以在第一次遍历中,我没有做,任何的交换因为1就是最小的。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • Figure out what I'm trying to walk through What's the collection of things I'm trying to walk through. Figure out what I want to do at each stage. Figure out what the end test is.

    弄清楚需要历的东西,弄清楚我需要历的东西的集合,弄清楚我在每一步该做什么,弄清楚终结测试。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I, somehow if, I want to walk through some sequence of data structures, gathering up or doing the same thing, adding ages in until I get a total age and then divide by the number faculty.

    我想,以某种方法,来遍历,一些数据结构,把它们相同的属性加到一起,就是一直的把年龄加到一起一直到,得到了一个年龄总数,然后除以员工的数目。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And that you might look at, for example, that first example, and say, man by this stage it was already sorted, yet it had to go through and check that the third element was in the right place, and then the fourth and then the fifth and then the six.

    你可能会去看看例如第一个例子,然后要抱怨,到这里,它已经是排好序的了,但他还是得去遍历查看,第三个元素是不是在正确的位置,然后第四个,第五个,第六个。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • And what it's saying semantically is, using that variable as my placeholder, have it walk through this collection, starting at the first thing, execute that code, then the next thing, execute that code, and so on.

    它的语义意思就是,把这个变量应用为我的占位符,用它来遍历这个集合,从第一个元素开始,执行代码,然后下一个元素,再执行代码。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • So the first one here is something called insertion sort which amounts to going through the list, taking the first thing that you see and inserting that element into its correct place, - then moving on to the next one, dealing with what element-- whatever element you're given and putting it in its right place.

    首先是插入排序,在此算法中,需要遍历整个列表,将你遇到的第一个元素放在其正确的位置,然后移动到下一个元素,继续处理-,不管是什么元素,都将其插入到合适的位置。

    哈佛公开课 - 计算机科学课程节选

  • So this isn't-- OK. And you're also close. It's going to be linear but how many times do I go through this?

    每次能丢掉一半,所以这里不是-,好的,但你也很接近了,他可能是线性的,但我得遍历多少次呢?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • How do I figure that out? Well I'm looping down the list, right? I'm walking down the list.

    怎么算出来的呢?我在循环,这个列表对吧?那要遍历这个列表。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I shouldn't say list, those two tuples, and walk through them to find the pieces that match up.

    除数数组进行对比,我不该说数组的,是元组,遍历这两个元组找到相同的元素。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • What's this thing doing? It's walking along the list looking for the smallest thing in the back end of the list, keeping track of where it came from and swapping it with that spot in the list. All right?

    这是在做什么?是在遍历列表,找列表后端最小的元素,跟踪它从哪里来的,然后同当前点的元素交换,明白了么?

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • It goes through and puts ones in the right place.

    遍历整个列表并提到正确的位置。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • But that little short hand there is doing exactly the same thing. It is adding that value into some digits and putting it back or signing it back into some digits. And I'll walk through that loop and when I'm done I can print out the total thing does. And if I do that, I get out what I would expect.

    加上得到的这个数的,但是这个缩写声明其实是进行了同样的操作,它把我们得到的这个数加到一个数上面去,然后用和对这个数进行了重新赋值,在循环中会去遍历字符串,当完成循环后,程序会显示数字的总和,如果我运行,这个程序的话,我会得到我期待的结果。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I'm going to give a name to that. And what you see there is I'm going to call divisors initially an empty tuple, something has nothing in it. Right here. And then I'm going to run through the same loop as before, going through this set of things, doing the check.

    你们可以看到这里,我初始化一个空的元组,名为divisiors,这里,然后我会去运行,跟以前一样的循环,遍历这个集合内的东西,然后做检查,现在我要做的是,每次我找到了一个除数我要把它收集起来。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • I can write it explicitly. I can write it inside of a FOR loop. And we've started to add, and we'll see a lot more of this, examples of collections of structures so that we don't just have to do something that can be easily described as walking through a set of things but can actually be a collection that you walk through.

    我可以明确的写出来,我可以把它在FOR循环的内部写出来,然后我们开始学习了add这个运算符,我们会在以后学习很多的,集合的数据结构的例子,这样一来我们可以进行一些,很简单的遍历集合的操作,我想要为大家指出的最后一件事情是。

    麻省理工公开课 - 计算机科学及编程导论课程节选

  • That is basically saying, given some collection of data, I want to have again a looping mechanism, where now my process is, walk through this, the collection one element at a time. And for that, we have a particular construct, called a FOR loop.

    现在我的过程就是,通过一个个访问这个集合中,的元素的方式,来遍历这个集合,为了达到这个目的,我们有一个特定的结构,成为FOR循环。

    麻省理工公开课 - 计算机科学及编程导论课程节选

$firstVoiceSent
- 来自原声例句
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定
小调查
请问您想要如何调整此模块?

感谢您的反馈,我们会尽快进行适当修改!
进来说说原因吧 确定