Skip to content

Instantly share code, notes, and snippets.

@zigzackey
Last active March 27, 2016 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zigzackey/282e92c34e5472afc3f5 to your computer and use it in GitHub Desktop.
Save zigzackey/282e92c34e5472afc3f5 to your computer and use it in GitHub Desktop.
def insertionSort(At, Nt):
for i in range(Nt):
v = At[i]
j = i - 1
while j >= 0 and At[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
print(" ".join(map(str,At)))
return At
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
A = insertionSort(A, N)
#print(" ".join(map(str,A)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment