public class Mergerecursion
{
public static void main(String[] args)
{
int[] arr={20,10,30,50,60,5,80,25};
int[] ans= mergeSort(arr, 0, arr.length-1);
for(int val: ans)
{
System.out.println(val+" ");
}
}
public static int[] mergeTwoSortedArrays(int[] arr1, int[] arr2)
{
public static int[] mergeSort(int[] arr, int low, int high)
{
if(low==high)
{
int[] base= new int[1];
base[0]=arr[0];
return base;
}
int mid=(low+high)/2;
int[] fh= mergeSort(arr, low, mid);
int[] sh= mergeSort(arr, mid+1, high);
int[] merge= mergeTwoSortedArrays(fh, sh);
return merge;
}
}
}