An interactive demonstration of the bubble sort algorithm
Visual Demonstration
Algorithm Explanation
What is Bubble Sort?
Bubble Sort is an intuitive sorting algorithm that works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they are in the wrong order.
Working Principle
1Compare adjacent elements in the array
2Swap them if they are in the wrong order
3Repeat until no more swaps are needed
Complexity Analysis
Time Complexity:O(n²)
Space Complexity:O(1)
Stability:Stable
Red bars indicate elements being compared, blue bars represent unsorted elements