Created
September 17, 2018 05:56
-
-
Save afishr/a4ec5558fd8ab2a941c33b949f5cf6c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Insertion sort | |
for (int i = 0; i < N; i++) | |
{ | |
int j = i; | |
while (j > 0 && array[j] < array[j-1]) | |
{ | |
// Swap array[j] and array[j-1] | |
swap(array[j], array[j-1]); | |
j--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment