You are viewing a single comment's thread. Return to all comments →
python3
def insertion_sort(l): count = 0 for i in range(1, len(l)): j = i-1 key = l[i] while (l[j] > key) and (j >= 0): l[j+1] = l[j] count +=1 j -= 1 l[j+1] = key return count m = input() l = [int(i) for i in input().strip().split()] print(insertion_sort(l))
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
python3