Logic of returning i+1 in partition function

I have understood till we swap the pivot element to its sorted position but why we return i+1 in last?

It gives you the place where your pivot element has gone. So you’ll call for
1 to i and i+2 to rest ( considering new posiition of pivot = i+1)

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.