You are viewing a single comment's thread. Return to all comments →
Python 3:
import sys def insertionSort1(n, arr): target = arr[-1] idx = n-2 while (target < arr[idx]) and (idx >= 0): arr[idx+1] = arr[idx] print(' '.join(map(str, arr))) idx -= 1 arr[idx+1] = target print(' '.join(map(str, arr))) if __name__ == "__main__": n = int(input().strip()) arr = list(map(int, input().strip().split(' '))) insertionSort1(n, 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 →
Python 3: