https://youtu.be/9I2oOAr2okY?
si=bXMuHTka-Q6gKzZ4&t=5
Tab 1
Turn on screen reader support
To enable screen reader support, press Ctrl+Alt+Z To learn about keyboard shortcuts, press Ctrl+slash
A Bubble Sorting Algorithm animated example
32 5 4 1
Ist 2nd 3rd 4th
3 2 5 4 1 23415 2 3 1 4 5 2 1 3 4 5
2 3 5 4 1 2 3 4 1 5 2 3 1 4 5 1 2 3 4 5
2 3 5 4 1 2 3 4 1 5 23145 i=3 1(c)
2 3 5 4 1 2 3 1 4 5 21345
2 3 4 5 1 i=1 3(c) i=2 2(c)
2345 1
2341 5 (i=0;i<=n-i;i++)
i=0 4(C) (j=0;j=n-i-1;j++)
Iteration comparison
1st (n-1)
2nd (n-2)
3rd (n-3)
N 1
(n-1)+(n-2)+(n-3)+.......1=n(n-1)/2
void bubbleSort(int arr[], int n) {
int i, j;
for (i = 0; i< n - 1; i++) {
for (j = 0; j < n - i - 1; j++) {
if (arr[ j] >arr[ j + 1]) {
// Swap arr[ j] and arr[ j+1]
int temp = arr[ j];
arr[ j] = arr[ j + 1];
arr[ j + 1] = temp; }