9. bubble, selection, insertion SORT

Selection Sort O(N^2)

1. Select minimum from curr till end
2. Swap minimum wala with curr
3. Repeat for n-1 elements


---------------------------------------------------------------------------------------------------------------
                                                          
                                         Bubble Sort O(N^2)
🥤


below is code for optimised bubble sort
since after each iteration in bubble sort, the largest element reaches the end

-----------------------------------------------------------------------------------------------------------------------------

Insertion Sort O(N^2)
🃏⭐

1. Front se chote chote array leke dekhte jao,
2. har baar ek se size badha do...
3. un chote arrays mein piche se aage shift karte raho.


-------------------------------------------------------------------------------------------------------------

Comments

Popular posts from this blog

30.) DP on subsequences

19. Strings (LB)

32. Binary Trees-2 (bfs/dfs med problems)