Sorting & Searching Visualizer

Visualize and understand how different sorting and searching algorithms work with interactive animations.

Sorting

Comp: 0Swaps: 0Time: 0.00s

Bubble Sort

1function bubbleSort(arr) {
2 const n = arr.length;
3 for (let i = 0; i < n - 1; i++) {
4 for (let j = 0; j < n - i - 1; j++) {
5 if (arr[j] > arr[j + 1]) {
6 // Swap
7 [arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
8 }
9 }
10 }
11}

Complexity:

  • Avg: O(n²)