You are viewing a single comment's thread. Return to all comments →
n=int(input()) arr=[int(x) for x in input().split()] def insertion_sort(arr): e=arr[len(arr)-1] ar=arr[0:len(arr)-1] l=len(ar) last=l-1 parr=[] while last>-1: # 2 4 6 8 tmp=ar[last] if tmp<e: break parr=ar[0:last]+[tmp]+ar[last:l] print (" ".join(str(s) for s in parr)) last=last-1 parr[last+1]=e print (" ".join(str(s) for s in parr)) insertion_sort(arr)
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →