插入排序

插入算法和選擇排序不同的是
默認(rèn)index = 0 為有序的
1.第一次循環(huán) 將index == 1 與index == 0 比較

2.若index 1 < index 0 則交換 他倆的位置

3.將 前兩個元素組成一個新的有序序列

4.繼續(xù)index +1 將無序序列的第一個元素 放置進(jìn)前面有序序列的正確位置(for 循環(huán)) 直到完成整個無序數(shù)列的排序

插入算法和選擇排序不同的是
默認(rèn)index = 0 為有序的
1.第一次循環(huán) 將index == 1 與index == 0 比較
2.若index 1 < index 0 則交換 他倆的位置
3.將 前兩個元素組成一個新的有序序列
4.繼續(xù)index +1 將無序序列的第一個元素 放置進(jìn)前面有序序列的正確位置(for 循環(huán)) 直到完成整個無序數(shù)列的排序