The next line says alright, suppose I don't, I'm not at the last element.
下一段说的是,好的,假设我不能放进去,我也不是在看最后一个元素。
All right, I've got to do one pass to bubble the last element to the end. I've got to do another pass to bubble the second last element to the end.
好的,我要冒一次泡来,把最大的元素冒到最后去,我还得再冒一次泡来吧第二大的元素。
First line says, 0 if i is 0, that means I'm looking at the very last element.
第一行的意思是,如果i的值是,就意味着我看到的,是最后一个元素。
OK. The next largest element has to end up in the second last spot. Et cetera. All right, so it's called bubble sort because it does this bubbling up until it gets there.
好的,下一个最大元素又,能跑到倒数第二的位置,等等如此,好的,这称为冒泡排序,因为这个泡泡一直冒到他自己的位置。
And that's like kind of hoping that the element you're searching for is the first in the list and the last in the list. Maybe.
也就是希望要找的元素,在数组的头部或者尾部,情况可能是这样的。
应用推荐