Interactive Algorithm Visualizer

    Practice data structures and algorithms visually. Use this free algorithm visualizer to see how sorting, searching, and pathfinding algorithms work step-by-step. Perfect for beginners, coding interview prep, and computer science students who want to understand Big-O time complexity with animations instead of just theory.

    Tip: Use a laptop or desktop for the best experience

    Bubble Sort

    Bubble Sort repeatedly swaps adjacent elements that are in the wrong order. It's easy to understand but inefficient on large arrays. Each pass through the array bubbles the largest unsorted element to its correct position.

    Time Complexity

    Worst
    O(n²)
    Average
    O(n²)
    Best
    O(n)
    Space Complexity
    O(1)

    Current Step

    Click Play to start visualization

    Implementation

    def bubble_sort(arr):
        n = len(arr)
        for i in range(n):
            swapped = False
            for j in range(0, n - i - 1):
                if arr[j] > arr[j + 1]:
                    arr[j], arr[j + 1] = arr[j + 1], arr[j]
                    swapped = True
            if not swapped:
                break
        return arr

    The LearnCodingFast algorithm visualizer is a free tool to practice Bubble Sort, Merge Sort, Quick Sort, Binary Search, BFS and more. Use it while learning data structures, preparing for FAANG-style coding interviews, or studying for computer science exams. Combine this page with our Python, JavaScript, and HTML & CSS courses to go from beginner to job-ready developer.

    Cookie & Privacy Settings

    We use cookies to improve your experience, analyze traffic, and show personalized ads. You can manage your preferences below.

    By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising. You can customize your preferences or reject non-essential cookies.

    Privacy PolicyTerms of Service