Randomized quick sort

condition of shuffle function (j=rand()%i+1) is wrong ?
this is right condition j=rand()%i ?

@khemchandrs function (j=rand()%(i+1)) is correct. rand()%(i+1) will generate any random number from 0 to i.
j=rand()%i will generate any random number from 0 to i-1.
Just follow the lecture video.

i index element we swap with (0 to i-1) index element if you says we generate index 0toi then some time i random index come then why are we swap ith index with ith index ?

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.