Mô phỏng thuật toán Sắp xếp nổi bọt

Bubble Sort · Nhóm: Sắp xếp

Sắp xếp nổi bọt (Bubble Sort), nhóm Sắp xếp.

Mã Python

def bubble_sort(a):
    n = len(a)
    for i in range(n - 1):
        for j in range(n - 1 - i):
            if a[j] > a[j + 1]:
                a[j], a[j+1] = a[j+1], a[j]
    return a

Mở trang để xem mô phỏng từng bước và xuất slide bài giảng.