What is linked list? Bubble sort
Anonymous
import json import json_wrapper import array as arr # Best O(n) | Average def bubbleSort(array): isSorted = False counter = 0 while not isSorted: isSorted = True for i in range(len(array) - 1 - counter): if array[i] > array[i + 1]: swap(i, i + 1, array) isSorted = False counter += 1 return array def swap(i, j, array): array[i], array[j] = array[j], array[i]
Check out your Company Bowl for anonymous work chats.