Why are we swapping the same indices?

In the function partition’s FOR loop, we are swapping if the array[j] < pivot.
But if you do dry run, the indices to be swapped will ALWAYS BE the same. So there is no use of swapping.
I have removed the swapping and even then the program is working fine in all cases.
Can you explain to me why do we need to swap inside the for loop?

@rahulrana1998
we are not swapping the same indices every time we swap some indices we increase the value of i swapping is the key part of the quicksort algorithm which brings all lesser element to the left side we can not skip it
int arr[] = {10, 7, 8, 9, 1, 5};
try this without swapping it will not work
if you still have a dout feel free to ask

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.