Skip to content

Instantly share code, notes, and snippets.

@msiddiqi
Created February 17, 2020 17:03
Show Gist options
  • Save msiddiqi/f599aad25ec69a0c7816a01df117d3a1 to your computer and use it in GitHub Desktop.
Save msiddiqi/f599aad25ec69a0c7816a01df117d3a1 to your computer and use it in GitHub Desktop.
public static void doInsertionSort(int[] arr)
{
for(int i = 1; i < arr.Length; i++)
{
var key = arr[i];
var j = i -1;
while(j>=0 && arr[j] > key)
{
arr[j+1] = arr[j];
j -= 1;
}
arr[j+1]= key;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment