Thumbnail for Visualization of Bubble Sort by G Bhat

Visualization of Bubble Sort

G Bhat

2m 17s323 words~2 min read
Auto-Generated

[0:00]Bubble sort. Bubble sort is a simple comparison based sorting algorithm. It sorts the elements by comparing the adjacent elements and rearranging them if they are in the wrong order. After every iteration, the highest element moves to the end of the array. It has best case complexity of O(n), average and worst case complexity of O(n²). Initialize the array. Set end = 8, i = 0 and j = 0. 5 < 9. No swap. 9 > 3. Swap. 9 > 1. Swap. 9 > 8. Swap. 9 > 6. Swap. 9 > 4. Swap. 9 > 2. Swap. 9 > 7. Swap. Set end = 7, i = 1 and j = 0. 5 > 3. Swap. 5 > 1. Swap. 5 < 8. No swap. 8 > 6. Swap. 8 > 4. Swap. 8 > 2. Swap. 8 > 7. Swap. Set end = 6, i = 2 and j = 0. 3 > 1. Swap. 3 < 5. No swap. 5 < 6. No swap. 6 > 4. Swap. 6 > 2. Swap. 6 < 7. No swap. Set end = 5, i = 3 and j = 0. 1 < 3. No swap. 3 < 4. No swap. 5 > 4. Swap. 5 > 2. Swap. 5 < 6. No swap. Set end = 4, i = 4 and j = 0. 1 < 3. No swap. 3 < 4. No swap. 4 > 2. Swap. 4 < 5. No swap. Set end = 3, i = 5 and j = 0. 1 < 3. No swap. 3 > 2. Swap. 3 < 4. No swap. Set end = 2, i = 6 and j = 0. 1 < 2. No swap. 2 < 3. No swap. Set end = 1, i = 7 and j = 0. 1 < 2. No swap. Set end = 0, i = 8 and j = 0.

[2:14]For more visit: gbhat.com

Need another transcript?

Paste any YouTube URL to get a clean transcript in seconds.

Get a Transcript