Randomised quick sort

cant we choose the pivot randomly instead o shufling the array?

@Shreya-Gupta-2383169445069382 , we can’t change the way we are choosing the pivot element in between the algo . yes , we can define different ways of choosing pivot like last element , first element, middle element etc. for every definition there is a worst case scenario that’s why we are shuffling the array such that worst case scenario has equal probability as other scenario

In case of any doubt feel free to ask :slight_smile:
mark your doubt as resolved if you got the answer

but in the algo we can create a random index and assign it to the pivot?

Yeah !! this way you can do it .
refer this for more info : -

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.