Last active
August 29, 2015 14:10
-
-
Save prasadwrites/7c54177187358e369f44 to your computer and use it in GitHub Desktop.
InsertionSort in Python
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
| def insertionsort(arr): | |
| for i in range(1,len(arr)): | |
| temp = arr[i] | |
| k = i | |
| while k>0 and temp < arr[k-1] : | |
| arr[k] = arr[k-1] | |
| k-=1 | |
| arr[k] = temp | |
| a = [999,45,343,3,34,556,233,645,2335,34,454] | |
| print(a) | |
| insertionsort(a) | |
| print(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment