Bubble Sort Visualization
if (arr[j] > arr[j+1]) {
swap(arr[j], arr[j+1]);
}Master the Fundamentals
Interactive visualizations to help you understand complex concepts. Perfect for interviews, coursework, or pure curiosity.
bubble-sort.ts
1 function bubbleSort(arr) {
2 for (let i = 0; i < n; i++) {
3 for (let j = 0; j < n-i-1; j++) {
4 if (arr[j] > arr[j+1]) {
5 swap(arr[j], arr[j+1]);
6 }
7 }
8 }
9 }
Step 24 / 56