MCPcopy Create free account
hub / github.com/BeeBombshell/Python-DSA / bubble_sort_optimized

Function bubble_sort_optimized

Sorting Algorithms/bubble_sort.py:11–20  ·  view source on GitHub ↗
(array)

Source from the content-addressed store, hash-verified

9
10
11def bubble_sort_optimized(array):
12 for i in range(len(array)):
13 swapped = False
14 for j in range(len(array)-i-1):
15 if array[j] > array[j+1]:
16 array[j], array[j+1] = array[j+1], array[j]
17 swapped = True
18
19 if not swapped:
20 break
21

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected