Created
January 25, 2015 19:03
-
-
Save sujayy1983/1121631c227b4315179f to your computer and use it in GitHub Desktop.
Implementaion of insertion sort.
This file contains 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
""" | |
@Author: Sujayyendhiren Ramarao Srinivasamurthi | |
@Description: Insertion sort | |
""" | |
def insertion_sort( data ): | |
length = len(data) | |
for idx in range(1, length): | |
val = data[idx] | |
while idx > 0 and val < data[idx-1]: | |
data[idx] = data[idx-1] | |
idx = idx -1; | |
data[idx] = val | |
return data | |
data = [10,5,8,900,100,25,6,1,0,53,500] | |
print insertion_sort( data ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment