You are viewing a single comment's thread. Return to all comments →
Here is my Python solution!
def insertionSort1(n, arr): insert = arr[-1] index = list(reversed([i for i in range(len(arr) - 1)])) for i in index: if insert <= arr[i]: arr[i + 1] = arr[i] else: arr[i + 1] = insert return arr arr[0] = insert return arr def insertionSort2(n, arr): for i in range(2, len(arr) + 1): print(" ".join([str (i) for i in insertionSort1(len(arr[:i]), arr[:i]) + arr[i:]])) arr = insertionSort1(len(arr[:i]), arr[:i]) + arr[i:]
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
Here is my Python solution!