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么?,对数次,对吧?就像刚才那位同学说的那样?
And we said that was log rhythmic, took log n time where n is the size of the list.
当列表的长度为n的时候,整个算法耗时log,n的时间。
And this is now consistent with my claim that I have sorted a list of size N equals 1.
这与我之前所说的是一致的,我已经将N为1的一个序列排好了序。
I'm accessing a list. How long does it take for me to get the nth element of a list?
我取得数组的第N个元素,需要多长时间呢?
Here's the problem. How do I get to the nth- er, the k'th element in the list, in this case?
如何找到第n个元素呢-,在这里,如何找到第k个元素呢?
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需要几次呢?
2 6 8 1 3 7 5 If I start off with fou, two, six, eight, one, three, seven, 8 five, so my list is of size N equals 8 at the moment.
顺序如下:,现在列表的大小N等于。
I now have a list of size 1 so N is, in fact, less than 2.
现在序列的大小是1,可见N小于。
I could still do the linear case, which is order n or I could say, look, take the list, let's sort it and then search it. But in that case we said well to sort it was going to take n log n time, assuming I can do that.
我仍然可以做O的线性搜索,或者也可以以这个列表为例,我们先将其进行排序,然后再进行查找,但是在这种情况下,要花费n,log,n的时间去对其进行排序。
应用推荐