Oh My Algorithm
Algorithm Guidecomplexity: O(n²)

Bubble Sort

Sorts by comparing adjacent elements, with larger values 'bubbling' up toward the end of the array — hence the name. Simple to implement, but unsuitable for large data.

01 Explore How It Works

Interactive Step-by-Step
Bubble Sort
45
12
89
34
67
23
56
10

버블 정렬을 시작합니다.

Logic Node1 / 12

02 Understand It Simply

For Everyone
🔑Analogy

Like bubbles rising to the surface, it compares two neighbors and pushes the larger one toward the end.

💡In Plain Words

Repeatedly compares neighbors and swaps them when they're out of order.

Simple but slow (O(n²)), so it's a poor fit for large data.

📍Where It's Used
  • Learning sorting concepts
  • small nearly-sorted data

03 Python Implementation

A clean, readable reference implementation of the core logic of Bubble Sort.

core_implementation.py
def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

04 Frequently Asked Questions

FAQ
What is Bubble Sort?+

Sorts by comparing adjacent elements, with larger values 'bubbling' up toward the end of the array — hence the name. Simple to implement, but unsuitable for large data.

What is the time complexity of Bubble Sort?+

The time complexity of Bubble Sort is O(n²). Follow the step-by-step visualization to see exactly why.

Where is Bubble Sort used?+

Learning sorting concepts, small nearly-sorted data.

What's a simple analogy for Bubble Sort?+

Like bubbles rising to the surface, it compares two neighbors and pushes the larger one toward the end.

Guide Progress0%