N But it's definitely not one and in fact it wasn't N in the case of Selection Sort because remember the algorithm we implemented on stage last week had me going back and forth across the stage selecting on iteration, the smallest person I can find, the smallest number and then putting them into place.
但在选择排序中,肯定不会是1,也不是,注意,上周我们在这儿,实现的算法中,反复地,迭代进行选择,选出最小的数,然后将其放在合适的位置。
> So now that might not have felt like the fastest algorithm but think about what you could have done with that algorithm in each iteration, much like the phonebook up front here, you literally split that problem in two because on each iteration roughly half of you were sitting down and then another half and then another half.
虽然这并不是最快的算法,但如果把这种算法每次迭代,就像刚才查电话簿一样,你便将这个问题一分为二了,因为每一次迭代后只有一半坐下来,以此类推。
And in this case, we go from 8 to 4 to 2 to 1 three times and then on each iteration of this algorithm, each pass across the board I'm touching N numbers, so that means I'm doing N things, log N times.
在这个例子中,我们从8得到4,到2,再到1,是3次,在这个算法的每次迭代中,每一趟我都会操作N个数,也就是所我每次要做N步操作,一共要做,log,N,次。
应用推荐