You are viewing a single comment's thread. Return to all comments →
I did about the same, but using a sentinel at the front of the array:
n, amin = int(input()), -10**4 A = [2*amin] + list(map(int, input().split())) for j in range(2, n+1): i, a = j, A[j] while a < A[i-1]: A[i] = A[i-1] i -= 1 A[i] = a print(*A[1:])
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 →
I did about the same, but using a sentinel at the front of the array: