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..
好,二分查找的基本前提,或者是我们建立二分查找的基础,我们已经有了一个排好序的元素列表,我们就需要知道如何来快速的排序,如何从列表中找到特定的元素。
What if I just get a list of elements, what do I do?
我们想想,不幸的是?
I've written a little for loop, which is going to iterate over all of the elements in the list.
让我们先看看这儿的代码,我已经写了一个循环语句,用来迭代处理数组中所有的元素。
These are sort of the cells, if you like, in memory that are holding the elements of the list.
记忆就像是数组中的元素,我们之前说的是,我在这里开始并且比较。
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.
我会取一个元素,然后去查看列表,来决定要把那个元素放到哪里,这就意味着它依赖于列表的长度,对,这没什么说服力,但是事实上。
For example, the number of elements in the list.
比方说链表中的元素个数。
Just as a 2-list, or a list of 2 elements.
来表示它们,就想一个二元数组。
应用推荐