So compare the front of this list which is 4 2 against the front of this list which is 2.
因此比较这个列表中的4和4,这个列表中的。
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应该是合并后列表的,下一个元素,然后你们就知道了。
Advance this pointer-- this finger, to the next element of the list which is 4, make the comparison.
前移这个指示器--也就是这根手指,让它指向列表中的,下一个元素4,再做比较。
I still have to do this process and here is where the finger thing gets a little more useful 'cause I have longer lists.
我仍需要进行这一步骤,在这儿手指的方法就比较有用,因为,列表比之前的要长。
Well let's see. My fall back is, I could just do linear search, walk down the list one at a time, just comparing those things. OK. So that's sort of my base. But what if I wanted, you know, how do I want to get to that sorted list? All right?
我只能做线性搜索了,一次遍历一遍列表,一个一个比较,但如果我想要,那怎样得到有序的列表呢?,现在的一个问题是,我们排序之前?
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次对比,因为我可以利用我知道的优势:,每次只需要比较每个子列表的第一个元素,那才是我需要进行对比的内容,当一个列表的元素处理完了,只需要将另一个列表剩下的元素直接添加进去。
应用推荐