bhaiya when j starts from i and initially min_ibdex value too i then how a[j]<a[min_index] work all the time
please help me by tracing this line
Why use a [j]<a[min_index]
@TheSourabh we keep min_index = i before second for loop and updated it inside second for loop, so i will remain same but min_index may change in second for loop.
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.
hello @TheSourabh there is nothing like a[j]<a[min_index] is working all the times itself only .
if you see the updated code in the second when the comparison results out to be true there we are updating the min_index .
and then we are comparing on the basis of the current updated value of min_index in the array .
if you dry run the code then you will definitely be able to understand how this is working .
if you feel that your doubt is cleared please mark this doubt as resolved .
Happy Learning !!
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.