Skip to content

Instantly share code, notes, and snippets.

@afishr
Created September 17, 2018 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afishr/a4ec5558fd8ab2a941c33b949f5cf6c0 to your computer and use it in GitHub Desktop.
Save afishr/a4ec5558fd8ab2a941c33b949f5cf6c0 to your computer and use it in GitHub Desktop.
// 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