Doubt in my code

Hello, I have just used pivot instead of a[e] but I am getting a unexpected output. Why is it so ?

Have a look at my code please :

helllo @yashsharma4304

check now->

yes that is my question that why we are using a[e] ?
because we have initialized the
pivot = a[e];

so both should be same thing na?

no both are not same.

when we are doing swap(a[e],a[i+1]) then two index of array is changing ie e and i+1

whereas in swap(pivot ,a[i+1]) only i+1 th index will get updaed , a[e] will remain same

1 Like

okkk, thanks for clearing my doubt :smile: .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.