Bubble Sort Algorithm Visualizer
Step-by-step visualization of Standard and Optimized Bubble Sort algorithms
1. Enter the Elements or Randomize Array
2. Click Start Sorting
3. Auto Run or Visualization → Next Step
Standard Bubble Sort
Optimized Bubble Sort
↑ Ascending Sort
↓ Descending Sort
🎛️ Control Panel
Auto Run Speed:
Normal
📊 Visualization
0
Current Step
0
Total Steps
0
Swaps
0
Comparisons
0
Current Pass
Enter numbers (0-100) and click "Start Sorting"
📋 Algorithm Logic
Select algorithm and click "Start Sorting" to begin the visualization.
🛈 About Bubble Sort
Standard Bubble Sort
Always performs n-1 passes, comparing all adjacent pairs each time. No early termination even if array is sorted.
Optimized Bubble Sort
Uses a swapped flag to detect if any swaps occurred. If no swaps in a pass, array is sorted and algorithm stops early.
Time Complexity
For Standard Sorting - Worst/Average/Best: O(n²)
For Optimized Sorting - Best: O(n) when array is already sorted. Worst/Average: O(n²)

