Why are we going till n-2?

in bubble sort why are we going till n-2; please explain

hi @uditmudgal07_2f40cca755bd8bd2 as u are cheking in next line with j+1 that will be n-2+1 i.e n-1 which is the last index of array and u want to sort till last index only

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.