Skip to content

Commit 9371ea2

Browse files
authored
Create Sort Nearly sorted array
1 parent 2c20f3e commit 9371ea2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
static void insertionSort(int A[], int size)
2+
{
3+
int i=0, k=0, j=0;
4+
for (i = 1; i < size; i++)
5+
{
6+
k = A[i];
7+
j = i-1;
8+
while (j >= 0 && A[j] > k)
9+
{
10+
A[j+1] = A[j];
11+
j = j-1;
12+
}
13+
A[j+1] = k;
14+
}
15+
}

0 commit comments

Comments
 (0)