And so, I need to cheat a little bit on the drawing and make sure that this minimum occurs right here.
所以,我需要在画时作点弊,以确保最小值出现在这儿。
So in the first case, I didn't have to do any swaps because 1 was the smallest thing.
所以在第一次遍历中,我没有做,任何的交换因为1就是最小的。
I only give, I don't know, about 10% or 20% for getting the right number in a computation. I tell my graders, if the student demonstrates minimal acceptable proficiency that student has to get a passing score.
我只是给,我不知道,10%或者20%的随机概率得到合适的数字,我告诉我的学生们,如果有人想证明,最小可接受的熟练,就是学生们得到一个及格的分数。
So I differentiated this object, this is my first derivative and I set it equal to 0 Now in a second I'm going to work with that, but I want to make sure i'm going to find a maximum and not a minimum, so how do I make sure I'm finding a maximum and not a minimum?
这样我就对它求出导数了,这是一阶导数,令它等于0,一会我们就要计算了,但我先确定一下是最大值还是最小值,我怎么确定是最大值还是最小值呢
I was just finding very tunnel vision-like, the smallest elements at that moment in time which means I don't know anything about the other elements other than they are not the smallest and so no matter what with Selection Sort I had to repeat this again and again and again and if you do out the math it's roughly N squared steps in the worst case as well.
我只有一个狭窄的视野,只知道某时刻的最小元素,就意味着我并不知道其他元素的任何情况,只知道它们不是最小的,所以不管怎样,在选择排序中,我就得一遍一遍地重复选择过程,在最坏情况下,大概需要N的平方次比较。
OK, that's not so bad. Moving a stack of size 2 if I want to go there, I need to put this one temporarily over here so I can move the bottom one before I move it over.
好,并不那么难,移动上面两个圆盘的话2,我需要把最小的盘子,临时先放到多余的柱子上来,这样才能在把它移过来之前,把最底下的盘子放到目标柱子上。
At the end of the first round, I've got the smallest element at the front. At the end of the second round, I've got the smallest two elements at the front, in fact I got all of them sorted out. And it actually runs through the loop multiple times, making sure that it's in the right form.
看看发生了什么,在第一轮结束后,我把最小的元素移到了前面,第二轮结束后,我把最小的,两个元素移到了前面,实际上,所有的元素都排好序了,实际上,这个算法运行了几次循环,确认下这是正确的形式。
应用推荐