About the selection sort

https://ide.codingblocks.com/s/373239 This is my shared url in which I get doubt, my doubt is that when i give input as
5
1 3 2 5 4
my output is 1 2 3 4 5 but i cant understand how output is starting from one according to code it should be null.
help me to solve my doubt by seeing and dry run code.

hello @manoj2597
the output is correct . it should be 1 2 3 4 5 only.

in ur code u r picking index of minimum and then u putting it as its correct location which is correct logic of selection sort

But i dont understand why output is starting from 1 when i dry run my code in condition if(a[j]<a[min_index]. Please help me to understand this

help me to understand this problem

here we are just comparing our previous min with current element a[j]
and if a[j] < a[min_index] then that means a[j] shuld be our new minimum hence we r updating min_index with j

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.