Python Program to Implement Insertion Sort
In this program, we will implement Insertion Sort
#Python program to implement Insertion sort
for i in range(1, len(a)):
temp = a[i]
j = i - 1
while (j >= 0 and temp < a[j]):
a[j + 1] = a[j]
j = j - 1
a[j + 1] = temp
a = input('Enter list elements: ').split()
a = [int(x) for x in a]
print('Sorted list: ', end='')
Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more.
Sign Up for our weekly newsletter to get update about new content.