I first had a list of size 8, then 4, then 2, but then I had another problem of size 2.
首先是一个有8个元素的序列,接着变成了4个元素,接着2个元素,然后我就碰到了有2个元素的另一个问题。
So compare the front of this list which is 4 2 against the front of this list which is 2.
因此比较这个列表中的4和4,这个列表中的。
Just to give you an example, here's one list, 1 2 4 30 3121724 Here's another list, 12430.
举个一例子来说,一个列表:3,12,17,24,另一个列表:
So here is a list of size 2, this is the light one, this is the heavier one.
这是有2个元素的一个序列,这杯轻一些,这杯重一些。
This is sorted, this is sorted, how do I now make a list of size 2?
这个是有序的,这个也是有序的,我怎样才能组成一个有2个元素的列表?
It says, well I'm going to print out first and last just so you can see it, and then I say, gee 2 if last minus first is less than 2, that is, if there's no more than two elements left in the list, then I can just check those two elements and return the answer.
然后它计算了尾点和开始点的差,如果小于2的话,也就是说数组中的元素小于等于,我对这两个元素进行比较,然后返回结果就可以了,否则的话,我们就去寻找中值点,注意它是怎么实现的,首先这个指向一个列表的开头。
So if I start off with a list of length n, how many times can I divide it by 2, until I get to something no more than two left?
我能够除以多少次2呢?,直到我得到的长度不超过2么?,对数次,对吧?就像刚才那位同学说的那样?
I've glued things together but just using a list.
我们因为角度为2的话,是沿着这个轴的。
So now, I have a list that's sorted of size 2.
现在大小为2的列表已排好序了。
I'm done sorting a list of size 2.
现在我已将这2杯排好序了。
Just as a 2-list, or a list of 2 elements.
来表示它们,就想一个二元数组。
Alright, here's the list of size 2.
这是一个有2个元素的列表。
N Well, here is a list of size N. How many times can you divide a list of size N by 2, right?
这是一个大小为N的列表,将一个大小为,的列表除以2需要几次呢?
OK, for example, I might say point p1 is that list, x is 1, y is 2.
和y坐标的数组是很简单的1,那么,例如,我可能会说点。
I now have a list of size 1 so N is, in fact, less than 2.
现在序列的大小是1,可见N小于。
应用推荐