Sorting Algorithm Visualizer — Bubble, Merge, Quick Sort Animated | Interview Prep Buddy
Back to Visualizers Hub
🔀

Sorting Algorithms

Sorting algorithms arrange elements in a specific order with different time/space trade-offs.

ALGORITHM PATTERN

Sorting Algorithms1. Bubble Sort

🎯 Expected:[1, 2, 4, 5, 8] (Sorted Array)
Milestones:
step 1 / 15
Step Execution Canvas
5
[0]
i
▲
2
[1]
8
[2]
1
[3]
4
[4]
Concept Code
1for i from 0 to n - 1:
2 for j from 0 to n - i - 2:
3 if arr[j] > arr[j + 1]:
4 swap(arr[j], arr[j + 1])
State
keyInsightBubble largest element to end in each pass by swapping adjacent out-of-order elements O(N^2).
i0
jNone
✏️
line 1💡 Key insight: Bubble sort repeatedly compares adjacent pairs (arr[j] > arr[j+1]) and swaps them if out of order, bubbling the largest element to the end in each pass.