直接插入排序
时间复杂度为:o()
空间复杂度为:o(1)
void InsertSort(int R[],int n)
{
int i,j;
int temp;
for(i=1;i<n;i++)
{
temp=R[i];
j=i-1;
while(j>=0 && temp<R[j])
{
R[j+1]=R[j];
j--;
}
R[j+1]=temp;
}
}
---------------------------------------------------------------
折半插入排序
基本条件:序列已经有序
时间复杂度:最好情况o(n),最差o(),平均o()
空间复杂度:o(1)