Quick_sort partition

in this line 17 if i give swap(a[pindex],a[e])
im getting a= sorted array

but if give swap(a[pindex],pivot) then im not getting the output ??? why is it so? when eventually a[e]=pivot???

@apoorv.chauhann, that’s because you are not swapping in the array , when you are doing swap(a[pindex],pivot), a[pindex] is indeed storing value of a[e] as you mentioned a[e]=pivot, but a[e] is not storing a[pindex] so ,there will be repetition of value of pivot value, at pindex and at e.

I hope you understood what i mean to say ,
In case of any doubt feel free to ask :slight_smile: