fabi.s

Generation

code to explanationFri, 25 Nov 2022

def bubbleSort(arr): n = len(arr) swapped = False for i in range(n-1): for j in range(0, n-i-1): if arr[j] > arr[j + 1]: swapped = True arr[j], arr[j + 1] = arr[j + 1], arr[j] if not swapped: return arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr)

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order.

Want to kickstart your project?Use the new AI Studio to create your code