11. Quick sort⭐

Divide & Conquer algorithm
time- NlogN,    space- 1

pick a pivot & place it in its correct position in sorted array
--------------------------------------------------------------------------------------------------------------------------
1. make low and high
2. choose pivot
3. take 2 pointers i=low & j=high
4. if, a[i] > pivot  &  a[j]<= pivot,  swap the two else i++ and j--
5. for one round do this till,  i>j
6. last mein pivot se swap karo
7. ab partition bangya, so 
put pivot in right place--> sort left and right half
------------------------------------------------------------------------------------------------------------------------































































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

Comments

Popular posts from this blog

18. greedy algorithm

19. strings (LB)

17. BINARY SEARCH on 2d arrrays