Bubble Shorting Video ( By Prof.Gade S A)

BY PROF.S.A.GADE
0

 


🔁 Bubble Sort - Short Notes


Definition:

Bubble Sort is a simple comparison-based sorting algorithm. It repeatedly compares and swaps adjacent elements if they are in the wrong order.


🧠 How It Works:


1. Compare the first two elements.

2. Swap if the first is greater than the second.

3. Move to the next pair and repeat.

4. After each pass, the largest element "bubbles up" to the end.

5. Repeat until the list is sorted.

--


📘 Example:


Original list: [5, 3, 8, 4]

Pass 1 → [3, 5, 4, 8]

Pass 2 → [3, 4, 5, 8]

Pass 3 → No swaps → Sorted!



---


🕒 Time Complexity:


Best case: O(n) (already sorted)


Average & Worst case: O(n²)



💾 Space Complexity:


O(1) → In-place sorting

--


✅ Advantages:


Easy to understand


Good for small datasets



❌ Disadvantages:


Very slow for large lists


Not suitable for real-time applications

                 ✍️Prof. Gade S G

     



Post a Comment

0Comments
Post a Comment (0)