Skip to content

Instantly share code, notes, and snippets.

@MichaelEstes
Last active August 29, 2015 14:17
Show Gist options
  • Save MichaelEstes/8988d918bed0e72f734d to your computer and use it in GitHub Desktop.
Save MichaelEstes/8988d918bed0e72f734d to your computer and use it in GitHub Desktop.
Int Array Insertion Sort in C++
void insertionSort(int arr[], int size)
{
int temp,j;
for (int i = 1; i < size; i++)
{
j = i;
while (arr[j] < arr[j - 1])
{
temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
j--;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment