C# program to Insert Sort int Array
public class Main{
static public void Insert_Sort(int[] array) {
int cnt = array.Length;
if (cnt == 1 || cnt == 0)
return;
for (int ii = 1; ii < cnt; ++ii) {
var elem = array[ii];
int jj;
for (jj = ii - 1; jj >= 0; --jj) {
if (array[jj] < elem)
break;
array[jj + 1] = array[jj];
}
array[jj + 1] = elem;
}
}
}
No comments