mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-25 23:09:36 +03:00
Update InsertionSort.c
This commit is contained in:
parent
ea50acb609
commit
41f0292531
@ -21,13 +21,13 @@ int main()
|
|||||||
{
|
{
|
||||||
// You'll enter the loop if the elmtToInsert is less than the element just before it.
|
// You'll enter the loop if the elmtToInsert is less than the element just before it.
|
||||||
|
|
||||||
arraySort[j+1] = arraySort[j]; /*shift the current element one place forward to create room for insertion of the
|
arraySort[j+1] = arraySort[j]; //shift the current element one place forward to create room for insertion of the elmtToInsert
|
||||||
elmtToInsert when the correct position is found */
|
|
||||||
j--;
|
j--;
|
||||||
}
|
}
|
||||||
//when we exit the loop, j+1 will be the index of the correct position of the elmtToInsert
|
//when we exit the loop, j+1 will be the index of the correct position of the elmtToInsert
|
||||||
|
|
||||||
arraySort[j+1] = elmtToInsert ; //'insert' the elmtToInsert into its correct position
|
arraySort[j+1] = elmtToInsert ; //'insert' the elmtToInsert into its correct position
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user