In the second case, I found in the next smallest element and moved here, taking what was there and moving it on, in this case I would swap the 4 and the 8, and in next case I wouldn't have to do anything.
在第二次遍历中,我找到了,第二小的元素,把它移到这里,把这里原来的元素移到哪里,在这一次遍历中,我会把8和4交换,然后一次遍历,不会做任何事情。
So the first one here is something called insertion sort which amounts to going through the list, taking the first thing that you see and inserting that element into its correct place, - then moving on to the next one, dealing with what element-- whatever element you're given and putting it in its right place.
首先是插入排序,在此算法中,需要遍历整个列表,将你遇到的第一个元素放在其正确的位置,然后移动到下一个元素,继续处理-,不管是什么元素,都将其插入到合适的位置。
应用推荐