It implies that this algorithm is calling itself again and again, and again, and on each time the size of the problem I'm trying to sort is being divided by what?
这就说明此算法会一次又一次地调用自己,每次我要排序的问题规模大小,会除以多少呢?
Now, we concluded last week at looking at sorts and efficiency, some new notation called asymptotic notation and we'll continue that story today.
上周我们着眼于排序和效率问题,并提出一些渐近线的新符号,今天我们将继续讨论相关内容。
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?
我只能做线性搜索了,一次遍历一遍列表,一个一个比较,但如果我想要,那怎样得到有序的列表呢?,现在的一个问题是,我们排序之前?
So Selection Sort, while it might be easier perhaps to think through than Bubble Sort, or maybe it's pretty much equivalent, it's just a different approach to the same problem.
因此,仔细想想,选择排序也许比,冒泡排序更简单,或者这两者都差不多,只是对同一问题的不同方法而已。
Alright, I have the problem so clearly this algorithm whatever it's gonna be is gonna be at least twice as fast because I'm doing half as much work.
现在,这个问题已变得清晰,不管怎么样,排序算法的效率,至少是之前的两倍,因为我只需要做一半的工作。
God bless. Oh, sorry, that wasn't a sneeze, it was a two? How many swaps do I do in bubble sort? A lot. Right. Potentially a lot because I'm constantly doing that, that says I'm running that inner loop a whole bunch of times.
上帝保佑,哦,抱歉,我没说清楚,这是两个问题,在冒泡排序中要做多少次排序?许多,正确的,可能要做很多次,因为在持续的干,这就意味着它要做很多次内部循环。
So I propose this as a new algorithm for sorting N elements and being 8 in this case or really a thousand in the case of the phonebook, or anything of larger size.
所以我提出一种新的算法,来解决N个元素的排序问题,在这个问题中N是8,在电话簿的问题中N是一千,或者是大规模的任何问题。
应用推荐