Created
June 2, 2014 16:42
-
-
Save Prince781/9b2a3fb4ccae678952e8 to your computer and use it in GitHub Desktop.
Simple insertion sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void insertion_sort(int *arr, int len) { | |
| int p; | |
| for (p=1; p<len; p++) { | |
| int n = arr[p], p2 = p; | |
| while (p2 > 0 && n < arr[p2-1]) | |
| arr[p2] = arr[--p2]; | |
| arr[p2] = n; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment