Objectives of this lecture
Insertion Sort:
void
InsertionSort(int list[])
{ int i, j , temp;
for(i
= 1; i < MAX_SIZE ; i++)
{ temp = list[i];
j
= i;
while((j-1 >= 0) && list[j-1] > temp)
{ list[j] = list[j-1];
j--;
}
list[j] = temp;
}
}
Index |
Original
|
Round1 |
Round3 |
Round
3 |
0 |
7 |
2 |
1 |
1 |
1 |
2 |
7 |
2 |
2 |
2 |
1 |
1 |
7 |
4 |
3 |
4 |
4 |
4 |
7 |