11. Quick sort⭐
Smart Divide & Conquer
( 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
------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment