# Insertion Sort
def InsertionSort(L):
for i in range(1,len(L)):
tmp = L[i]
for j in range(i,-1,-1):
if(tmp>L[j-1]):
break
L[j] = L[j-1]
L[j] = tmp
print(L)
L = eval(input("Enter list of elements : "))
InsertionSort(L)
"""
Sample output
>python InsertionSort.py
Enter list of elements : [34,8,64,51,32,21]
[8, 21, 32, 34, 51, 64]
"""
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu