When does lo cross hi in quick sort

I just want to understand why we take base condition as
if(lo >= hi) { return };

I dont understand when lo becomes greater than hi anywhere as I think condition should work fine even if it is just lo == hi but it does not work and error is shown. can u explain pls…

Hey @code_breaker-1001 It is giving error bcoz when lo == hi there can be a case after looping through while loop in the code that left becomes greater than right so in that case we will be making a call of lo > hi which is inappropriate due to which we take lo >= hi.

Ohh Thank You…

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.