Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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
You can’t perform that action at this time.