PYTHON PROGRAM
n=int(input("Enter array size:"))
print ("Enter",n,"elements in Array:")
a=[]
for i in range(n):
s=int(input())
a.append(s)
for i in range (1,n):
temp=a[i]
j=i-1
while (j>=0 and a[j]>temp):
a[j+1]=a[j]
j -=1
a[j+1]=temp
print ("Element of Array after Insertion Sort are:")
for i in range(n):
print (a[i])
No comments:
Post a Comment
let me know which type examples you want to comment me.