Quicksort algorithm

sir in quicksort , when we encounter a number less than pivot, we do increment the smaller part and this makes our i=j means smaller part last index and greater part first index is coinciding . then why are we swapping the same element and how our value of j is incrementing in that case, unlike in greater element case where we written j=j+1;

hello @tejuschaturvedi0

we are always updating j irrespective of what value we are getting.

we will never encounter i==j condition.
becuase in the start i< j and j is incremented by 1 after every iterator wherease i only when a particular condition occurs. so even if i is getting increment always it will remain i<j

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.