Doubt in condition

in the following video please explain how the following condition is getting implemented if(si==li) then bubblesort(arr,0,li-1) and after that return statement is applied so is it means that the following succeding code written below it wil not work

Hi @dheerajmishra992,
See the concept of bubble sort is to get the largest element to the last .Hence in this if the si==li that means that the selected index is last index so we have the largest element at last index li so we decrease li to li-1 so that the next largest number can be brought till li. So this process is taking place in the above if loop. In case arr[si]>arr[si+1] so we switch which is obvious as we want the larger element at a greater index . Further down this we have that if this is not the condition we increase si to si+1 and recursively call the function again .

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.