首页 > IT职业 > IT图书 > 插入排序算法优化(Java)
/**
* Created by yuyong on 2017/3/2.
*/
public class InsertionSort {
public void insertionSort(int arr[], int n) {
for (int i = 1; i 0 && arr[j - 1] > temp; j--) {
arr[j] = arr[j - 1];
}
arr[j] = temp;
}
}
public static void main(String[] args) {
int[] a = {10, 8, 1, 5, 2, 9, 7, 6, 4, 3};
InsertionSort is = new InsertionSort();
is.insertionSort(a, 10);
for (int i = 0; i 来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3996/viewspace-2807547/ ,如需转载,请注明出处,否则将追究法律责任。