What will happen when instead of return bubble2sort() when j==n-1 we simply called bubble2sort() without return statement

recursive call with return statement works in different way? please explain how

hello @the.shubham.sri
if we not use return in that if statement ,then whatever statement written after that if,will execute and error will occur.
becuase u will try to access j and j+1 ,where j =n-1 and j+1=n,we cannot acces index n in our array(because array size is n ,index range from 0 to n-1) this will give error

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.