• I look at the rest of the list to decide what's the element to swap into the next place.

    我会查看列表剩下的部分,来看看需要交换哪个元素。

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

  • And if I'm walking down the list, this is probably order of the length of the list s because I'm looking at each element once.

    这可能大概就是数组的长度,因为我会遍历数组中的每个元素一次,现在你可能会想,等等,数组已经排好序了。

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

  • Advance this pointer-- this finger, to the next element of the list which is 4, make the comparison.

    前移这个指示器--也就是这根手指,让它指向列表中的,下一个元素4,再做比较。

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

  • So wherever the largest element started out in the list, by the time I get through it, it's at the end.

    所以无论最大的元素,在列表的什么位置。

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

  • Right, so s of i saying, given the list, look at the i'th element, true is it the same thing?

    第2个元素,看他们是不是相等呢?,如果他们相等,好,把答案设置为?

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

  • Now, compare the first element in each of these lists. Two is less than three, so two ought to be the next element of the list.

    现在,比较每个列表的第一个元素,2要比3小,所以2应该是合并后列表的,下一个元素,然后你们就知道了。

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

  • If I do this, try and get the 10th element of a list that's only eight long. I get what looks like an error, but it's actually throwing an exception.

    如果我来这么做,试着去取长度为8的列表的第十个元素,我貌似能得到一个错误。

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

  • Because if you did what I suggested with the list, the time to look up the key would be linear in the length of the list. You'd have to look at each element until you found the key.

    字典是用一种很神奇的,叫做散列法的算法,来实现的,后面我们将,会学到一点关于。

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

  • When you are searching a list to see whether it has an element, you don't randomly probe the list, hoping to find whether or not it's there.

    当我们在一个数组中,寻找目标元素的时候,我们不会随机的调查数组来看。

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

  • So the first thing we'll do is, we'll print the element, in this case it will be a list right? Because it's a list with two lists in it.

    因此这儿我们要做的第一件事,就是要显示元素,在这儿元素就是数组了对不对?,因为这个数组包含了两个数组。

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

  • But if, at any point, I get to a place in the list where the thing I'm looking for is smaller than the element in the list, I know everything else in the rest of the list has to be bigger than that, I don't have to bother looking anymore.

    比当前位置数组的元素要小,我也就知道后面的数肯定,也都比我的目标数要大了,我就不用再继续进行下去了,这意味着目标数不在这个数组中,我就可以退出了。

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

  • I've got a list, walk you through it an element at a time, do I look at each element of the list more than once?

    你一次只能得到他的一个元素,我是不是把数组里面的每个元素,都过了大于等于一次?,你不这样认为么?大家有什么建议?

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

  • Again. Basic premise of binary search, or at least we set it up was, imagine I have a sorted list of elements. We get, in a second, to how we're going to get them sorted, and I want to know, is a particular element in that list..

    好,二分查找的基本前提,或者是我们建立二分查找的基础,我们已经有了一个排好序的元素列表,我们就需要知道如何来快速的排序,如何从列表中找到特定的元素。

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

  • And in the next spot, maybe I've got a really long list, and I'm going to say how to jump to get to the next element.

    可能我得存放一个很长的列表了,你们也明白如何定位下一个元素,好的,这很棒,这样我有一个。

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

  • Lisp The problem with that technique, while it's very general, is how long does it take me to find the i'th element of the list?

    很多编程语言包括,都是用了这种技术,这个问题就是,当数组很大的时候?

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

  • And that's like kind of hoping that the element you're searching for is the first in the list and the last in the list. Maybe.

    也就是希望要找的元素,在数组的头部或者尾部,情况可能是这样的。

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

  • Hmm. Well, wait a minute. If I want to sort a list, I'll take one element, I've got to look at probably a lot of the other elements in the list in order to decide where it goes. And that suggests it's going to depend on how long the list is.

    我会取一个元素,然后去查看列表,来决定要把那个元素放到哪里,这就意味着它依赖于列表的长度,对,这没什么说服力,但是事实上。

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

  • And the example I want to look at is, suppose I want to search a list that I know is sorted, to see if an element's in the list.

    看看目标元素在不在数组里,也就是说我要去,检索一个有序的数组。

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

  • Sure. So that says one should be the first element in my merge list.

    所以可以确定1应该是合并后的,列表的第一个元素。

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

  • Well, I might move my hands here 'cause this list only has one element left.

    我会将手移到这边,因为这个列表中,只剩下一个元素了。

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

  • 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.

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

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

  • OK. And I'm going to look to see, is a particular element inside of that list, and again, I'll remind you, that's just giving me the integers from zero up to 9999 something or other.

    一个又大又长的列表吧,好的,我打算查找列表中的一个特定元素,我会告诉你,我用的是0到大概是,9999左右的整数。

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

  • The easy thing to do would be the following: start at the front end of the list, check the first element. If it's the thing I'm looking for, I'm done. It's there. If not, move on to the next element. And keep doing that.

    从数组的第一个元素开始:,如果这是目标元素那么结束,如果不是的话就继续比较下面的元素,并一直这么比较下去,但如果,在某一点我发现我要寻找的数字。

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

  • That one's not so obvious. So let's think about this for a second. To sort a list in linear time, would say, I have to look at each element in the list at most a constant number of times.

    所以让我们来思考一会,要在线性时间能排序,列表里每个元素最多被使用常数次,不一定是一次,对吧。

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

  • I'm accessing a list. How long does it take for me to get the nth element of a list?

    我取得数组的第N个元素,需要多长时间呢?

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

  • What's the last element in the list look like?

    列表中最后一个元素是什么样呢?

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

  • It took me seven comparisons, because I can take advantage of the fact I know I only ever have to look at the first element of each sub-list. Those are the only things I need to compare, and when I run out of one list, I just add the rest of the list in.

    进行了7次对比,因为我可以利用我知道的优势:,每次只需要比较每个子列表的第一个元素,那才是我需要进行对比的内容,当一个列表的元素处理完了,只需要将另一个列表剩下的元素直接添加进去。

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

  • We're going to call binary search, it's going to take the list to search and the element, but it's also going to say, here's the first part of the list, and there's the last part of the list, Well, it checks to see, is it bigger than two?

    我们将要调用这个二分查找,它将会在列表里面搜索元素,假定这里是,列表的第一个元素,那里是列表的最后一个元素,代码内部到底做了什么?

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

  • Here's the problem. How do I get to the nth- er, the k'th element in the list, in this case?

    如何找到第n个元素呢-,在这里,如何找到第k个元素呢?

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

  • We have a pointer to the location in memory that contains the actual value, which itself might be a bunch of pointers, and we have a pointer to the actual-- sorry, a pointer the value and we have a pointer to the next element in the list. All right?

    包含实际值的地址,可能实际值,也是一系列指针,这里还有指向实际,抱歉,指向下一个元素的指针,我们来整理下?

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

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

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

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