Still quadratic, right? I'm looking for the worst case behavior, it's still quadratic, it's quadratic in the length of the list, so I'm sort of stuck with that.
还是平方,对吧,我在寻找最坏的情况,它还是平方,它是列表长度的平方,我对此有点无奈了。
And I'll also remind you, and we're going to see this in the next example, we talked about looking at the worst case behavior. In these cases there's no best case worst case, it's just doing one computation.
我还要提醒大家的就是,我们也会在下一个例子里发现者一点,我们谈到了要去考虑最坏的情况,在下面这些例子里,没有好情况坏情况之分,就只是一次运算。
And so you care-- you care about ultimately how much time is my algorithm gonna take to perform on that worst case running time.
因此你最终所关心的是,算法在最坏情况下需要多长的,运行时间。
The other obvious one to do would be worst case. Again, over all possible inputs to this function, what's the most number of steps it takes to do the computation?
很明显另一种就是针对最坏的情况了,也就是在所有可能的输入,里面选出用的,步骤最多的那个输入?
The second one is, a lot of the time, the worst case is the one that happens.
第二点就是,在很多情况下,发生的往往就是最坏的情况。
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的平方次比较。
应用推荐