Insertion Sort In Python
def insertion_sort(lst):
for i in range(1, len(lst)):
temp = lst[i]
j=i-1
while(j>=0 and temp<lst[j]):
lst[j+1]=lst[j]
j-=1
lst[j+1]=temp
print(lst)
lst = [90,65,12,98,31,20,89,71,90]
insertion_sort(lst)
Comments
Post a Comment