Running Time of Algorithms

  • + 0 comments
    def runningTime(arr):
        k = 0
        for i in range(1,  len(arr)):
            for j in range(i):
                if arr[i-j] < arr[i-j-1]:
                    arr[i-j], arr[i-j-1] = arr[i-j-1], arr[i-j]
                    k += 1
        return k