I have written the same code as taught by sir in the video. I trying to write the code of bubblesort using recursion but getting stckoverflow exception.
package practise;
public class recursion {
public static void bubbleSort(int[] b,int si,int li)
{
if(li==0)
{
return;
}
if(si==li)
{
bubbleSort(b, 0, li–);
return;
}
if(b[si]>b[si+1])
{
int temp=b[si];
b[si]=b[si+1];
b[si+1]=temp;
}
bubbleSort(b, si+1, li);
return;
}
public static void main(String[] args) {
int[] c= {50,40,30,20,10};
bubbleSort(c,0,c.length-1);
for(int i : c)
{
System.out.print(i+" ");
}
}
}