def insertion_sort(arr):
for i in range(1, len(arr)):
key = arr[i]
j = i-1
while j = 0 and key arr[j] :
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key

arr = [5,3,7,1,9,4,6,2,8,0]
insertion_sort(arr)
print("Sorted array is:", arr)

What is the output of the following python program

Posted on by