def bubbleSort(arr): n = len(arr) # optimize code, so if the array is already sorted, it doesn't need # to go through the entire process swapped = False # Traverse through all array elements for i in ...
For more information about the time complexity, you can take a look at the Big O Table. Bubble sort is one of the most straightforward sorting algorithms, it makes multiple passes through a list.