Day 9/366

Rmag Breaking News

🚀 Today’s Learning:

🌟 DSA

Bubble sort
Selection Sort

🌟 Dev

Features of React
JSX

🔍 Some Key Highlights:

In bubble sort, we just compare the current element with the next element → if the current element is greater than next element it is swapped → This let the maximum element reach the end of the array. Now the unsorted array left is till the second last element. Same process is repeated for sorting this array and so on. Finally we get the sorted array. There is an outer loop ‘i’ which runs from n-1 to 0. And an inner loop ‘j’ that runs from 0 to i-1 (not till i coz we are comparing A[j] and A[j+1]). Avg and worst case T.C. O(n2) | Best case: O(n) (when the array is already sorted)

100daysofcode #1percentplusplus #coding #dsa

Leave a Reply

Your email address will not be published. Required fields are marked *