Python - What is the space complexity when tuple swap is used in bubble sorting?
问题 Consider the following bubble sort program: arr = map(int, raw_input().split(' ')) print "Unsorted: \n{arr_name}".format(arr_name = arr) for j in range(len(arr) - 1, 0, -1): for i in range(j): if (arr[i] > arr[i + 1]): arr[i], arr[i + 1] = arr[i +1], arr[i] print "Sorted: \n{arr_name}".format(arr_name = arr) Usually a temp variable is used for sorting and that would be mean a space complexity of 0(1) . But my understanding is that, tuple swap is only a reassignment of identifiers to objects