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 I'm first going to look for something that's not in the list, I'm going to see, is minus 1 in this list, so it's going to be at the far end, and if I do that in the basic case, bam.
如果我试试第一种最基本的方法,噢,一下就完成了对不对?,因为这种方法查了下第一个元素,然后发现目标数比较下,因为目标数小于第一个元素。
And, furthermore, they are characteristic of the target gas element.
更进一步的说,它们是目标气体元素的特征。
And in here, there's a very male-dominated theme that you'll see pretty quickly, and what you'll see in this is that this man is being told, and men who watch it, obviously a male-oriented sort of thing that I've seen watching sporting events and the like.
这个广告片,有个明显的男权主题,你们马上就能看到了,你们会看到在这个广告中这个男人在聆听,还有在看的男人,显然这是个以男性为主要目标的广告,我看到了类似运动比赛的元素
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.
并且保持遍历,我只在当当前位置的数组元素,大于目标数时停止,这意味着剩下的元素都比目标元素大,但是其他的情况,我还是要遍历完整个数组。
You find some way of systematically going through the list. Yet, I often see people, when they're debugging, proceeding at what, to me, looks almost like a random fashion of looking for the bug.
是不是目标元素,我们有一种系统化的,遍历数组的方法,然后我经常看到,有些人调试的时候。
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.
看看目标元素在不在数组里,也就是说我要去,检索一个有序的数组。
OK? So the example I'm going to do, I'm going to search a sorted list.
来搜索目标元素,好,翻到课堂材料的第二页。
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.
从数组的第一个元素开始:,如果这是目标元素那么结束,如果不是的话就继续比较下面的元素,并一直这么比较下去,但如果,在某一点我发现我要寻找的数字。
We're about to start talking about the elements of the language, but to do that, we also need to separate out one last piece of distinction.
我们将会开始讨论,语言的元素,但是为了达到这个目标,我们还需要去做,最后的一个区分。
But we know lists can be composed of anything.
在数组中取得目标元素,是一个基本步骤。
应用推荐