top of page

Bubble Sort: A Deep Dive Part 2

Writer's picture: Samvar ShahSamvar Shah

Updated: Nov 13, 2024



Continuing from Part 1 of the post on Bubble Sort, here is a visualizer that helps us see how bubble sorting is carried out. Click on the' Start Bubble Sort' button in the graph above for a live view of how the sorting is carried out.


You will notice that the animation shows the step-by-step process of Bubble Sort, highlighting how elements are compared and swapped.


Conceptual Animation Steps:


  1. Initial Array:

    • Display the unsorted array: [64, 34, 25, 12, 22, 11, 90] *The animation above picks any randomly generated unsorted array.

  2. Passes:

    • It then swaps adjacent elements where needed. For example, during the first pass:

      • Compare 64 and 34, swap them.

      • Compare 64 and 25, swap them.

      • Continue this until the largest element (90) is placed in its correct position.

  3. Subsequent Passes:

    • Show each subsequent pass with fewer elements being processed, and the array getting progressively sorted.


Conclusion

Hopefully this visualization gave a clearer understanding of how Bubble Sort works in a phased manner.

12 views1 comment

Recent Posts

See All

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Aadvik Jain
Aadvik Jain
Nov 12, 2024
Rated 5 out of 5 stars.

Liked it a lot!! 😀

Like
bottom of page