直接插入排序

来源:互联网 发布:万方数据库 知网 编辑:程序博客网 时间:2024/06/17 10:35

直接插入排序算法的时间复杂度为o(n*n)

void InsertSort(int *a,int Length){int i,j;for(i =1;i<Length;i++){if(a[i]<a[i-1]){int temp = a[i];for(j = i-1;j>=0&&temp>a[j];j--)a[j+1] = a[j];a[j+1] = temp;}}}


0 0