def sort(l): n = len(l) - 1 for i in range(n*n): pos = i % n if l[pos] > l[pos+1]: l[pos], l[pos+1] = l[pos+1], l[pos]
time complexity is O(n^2).
The time complexity is O(n^2).
Since, in 1st run there is two loop running one till n-1 and other till n.
So, n*(n-1)= n^2… Smallest element(n*1) is ignored during time complexity.
time complexity is O(n^2) given the complexity n to the first loop and then to the if statement i.e n^2