Good day for everyone I hope you are very well.
My question is this, I am trying to implement this pseudocodigo in java programming language:
But the truth is I'm very new to issues of using recursion, I've tried in many ways but I really can not do it recursively, for the moment I've done this:
public class MergeSort
{
public static void main(String[] args)
{
int unsorted_array[]= {8,9,3,4,2,1};
int sorted_array[]=new int [unsorted_array.length];
int MergeSort (int unsorted_array[], int n,int left_sub_array,int right_sub_array[])
{
if(unsorted_array.length==1)
return unsorted_array[n];
else {
//split in two parts
left_sub_array=unsorted_array[0]/unsorted_array[n/2];
right_sub_array=unsorted_array[(unsorted_array.length/2)+1]=unsorted_array[unsorted_array.length];
}
return left_sub_array;
}
}
}
I add that I have to use a function that reads the numbers by the user separated by a comma and I know that it is as follows:
String[] numeros=br.readLine().split(",");
int[] array = new int[numeros.length];
for(int i = 0; i < numeros.length; i++) {
array[i] = Integer.parseInt( numeros[i] );
}
for(int i = 0; i < numeros.length; i++) {
System.out.print(numeros[i]+" ");
}
but as I said, I would not know where to put this function in a recursive algorithm.
I would really appreciate if you could give me a help, thank you very much.