So it's certainly at least linear in the length of the list. For each starting point, what do I do?
它至少是线性的计算列表的长度,每次到了循环开始的点?
First, it's pointing to the beginning of the list, which initially might be down here at but after a while, might be part way through. And to that, I simply add a halfway point, and then I check.
列表中间的一个部分了,然后我求出列表的中值点,然后看看该点的值是不是等于目标值,如果是的话就完成了,如果不是的话,如果中位值大于我要找的目标值。
You will be given a list of pieces that you'll have to prepare for a little bit and then we will play out of those particular pieces, but most importantly, I will give you a prep sheet.
回头我会给你们一个作品片段的列表,你们得做点准备,然后我们会放一些列表中的作品片段,但是最重要的是,我会给你们一些考点
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的话,也就是说数组中的元素小于等于,我对这两个元素进行比较,然后返回结果就可以了,否则的话,我们就去寻找中值点,注意它是怎么实现的,首先这个指向一个列表的开头。
应用推荐