AiTechWorlds
AiTechWorlds
Watch Bubble, Selection, Insertion, Merge, and Quick Sort step-by-step with synced code, step explanations, and side-by-side comparison.
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]Bubble Sort repeatedly compares adjacent elements and swaps them when out of order, letting the largest values "bubble" to the end on each pass.
| Best | O(n) |
| Average | O(nΒ²) |
| Worst | O(nΒ²) |
| Space | O(1) |
| Stable | Yes |
| In-place | Yes |
The Sorting Algorithm Visualizer on AiTechWorlds animates common sorting algorithms step by step so you can watch exactly how each one works. Sorting algorithms are a core topic in computer science education and technical interviews, but they are far easier to understand visually than by reading pseudocode alone. This tool animates bubble sort, selection sort, insertion sort, merge sort, quicksort, and heap sort with color-coded bars showing comparisons, swaps, and sorted elements at each step. Adjust the array size and animation speed, step through manually, or run continuously. The visualizer also shows the current time and space complexity, comparison count, and swap count. Everything runs in your browser β AiTechWorlds built this for CS students, interview candidates, and anyone learning algorithms.
Select an algorithm
Choose from bubble sort, selection sort, insertion sort, merge sort, quicksort, or heap sort.
Set array size and speed
Adjust the number of elements and animation speed sliders.
Generate a new array
Click Randomize to generate a new unsorted array.
Start visualization
Click Sort to watch the animation, or use Step mode to advance one step at a time.
Read the stats
Observe the comparison count, swap count, and time complexity displayed during sorting.
100% Private β No Server Required
All processing happens directly in your browser. No data is uploaded, stored, or transmitted to any server.
Last reviewed on June 1, 2026 by the AiTechWorlds Tools Team. All processing runs locally in your browser.
Advertisement