# Written by Eric Martin for COMP9021


def bubble_sort(L):
    bound = len(L) - 1
    swapped = True
    while swapped and bound:
        swapped = False
        for i in range(bound):
            if L[i] > L[i + 1]:
                L[i], L[i + 1] = L[i + 1], L[i]
                swapped = True
                bound = i

Resource created 10 years ago.

file: bubble_sort.py


Loading...


Back to top

COMP9021 15s2 (Principles of Programming) is powered by WebCMS3
CRICOS Provider No. 00098G