💩

programierds

algorithms / sorting

Bubble Sort
Step by Step

Visualize how elements 'bubble up' to their correct positions. Use the controls to follow the logic line by line.

C Implementation Line: -
1int arr[] = {5, 1, 4, 2, 8};
2int n = 5;
3for (int i = 0; i < n - 1; i++) {
4  for (int j = 0; j < n - i - 1; j++) {
5    if (arr[j] > arr[j + 1]) {
6      int temp = arr[j];
7      arr[j] = arr[j + 1];
8      arr[j + 1] = temp;
9    }
10  }
11}
i -
j -
Array Visualization
Click "Start" to begin the animation.
Paso 0 / 0
← Back to all presentations