Bubble sort recursion

sir how can I know when to use return statement and when not to use it??

like in recursive bubble sort version:

if(size==1)
return;
if(j==size-1)
return bubble_sort2(array,size-1,0);
if(array[j]>array[j+1])
swap(array[j],array[j+1]);
bubble_sort2(array,size,j+1);

in the base condition we use it , while in comparisons part we do not use like in the last statement!

hello @mzk1994 in base case we are making use if return statement the basecase hits when you are on the last call.
so there must be something in return from the last call thats why we have to make the return statement here.
when you go somewhere either you are going to get some knowledge about the task or you have to provide knowledge about the task that what is result till now.
whenever there is a fucntion call of non void then we have to return something from the function.
if you still have any doubt you can ask here.
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.