Why j<=n-2 in iterative case it should be j<=n-1;

why j<=n-2 in iterative case it should be j<=n-1;

@Aditya-Kushwaha-914550392281281
hello Aditya,
after j==n-2 ,all array elements will be in sorted order .

so iterating for one more time will be redundant.
btw u can use j<=n-1 it will also give correct order.

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.