input: Write a python function to implement the bubble sort algorithm.
  assert bubble_sort([12, 3, 10, 7, 5, 11]) == [3, 5, 7, 10, 11, 12]
  assert bubble_sort([5, 3, 8, 4, 2]) == [2, 3, 4, 5, 8]
  assert bubble_sort([]) == []
  assert bubble_sort([1]) == [1]
output: def bubble_sort(arr):
      n = len(arr)
      for i in range(n):
          swapped = False
          for j in range(0, n-i-1):
              if arr[j] > arr[j+1]:
                  arr[j], arr[j+1] = arr[j+1], arr[j]
                  swapped = True
          if not swapped:
              break
      return arr