0% found this document useful (0 votes)
22 views3 pages

B Sort

The document provides an animated example of the Bubble Sorting Algorithm, illustrating the sorting process through iterations. It includes a visual representation of the sorting steps and the corresponding comparisons made during each iteration. Additionally, a sample code snippet for the Bubble Sort function in C is presented.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

B Sort

The document provides an animated example of the Bubble Sorting Algorithm, illustrating the sorting process through iterations. It includes a visual representation of the sorting steps and the corresponding comparisons made during each iteration. Additionally, a sample code snippet for the Bubble Sort function in C is presented.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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; }

You might also like