https://online.codingblocks.com/player/3516/content/483
the recursion video for java data structure of bubble sort.
public class Main {
public static void main(String args[]) {
int[] arr = {25, 14, 56, 15, 36, 56, 77, 18, 29, 49};
int[] ans=PD(arr.length,0,arr);
for(int i=0;i<9;i++)
System.out.println(ans[i]);
}
public static int PD(int li,int si,int[] arr)
{
if(si==li){
PD(li-1,0,arr);
return ;
}
if(li==0)
return;
if(arr[si]>arr[si+1])
{
int temp=arr[si+1];
arr[si+1]=arr[si];
arr[si]=temp;
}
PD(n,si+1,arr);
}
}
i m getting an error
Main.java:4: error: incompatible types: int cannot be converted to int[]
int[] ans=PD(arr.length,0,arr);
and
Main.java:15: error: incompatible types: missing return value
return ;