Skip to content

Instantly share code, notes, and snippets.

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]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment