static void sort(int array[])
{
//int array[]={20,40,30,60,70,80,50,90};
if(array.length==1)
return;
int mid=array.length / 2;
int part1[]=new int[mid];
int part2[]=new int[array.length-mid];
for(int i=0; i<array.length; i++)
{
if(i<mid)
{
part1[i]=array[i];
}
else
{
part2[i-mid]=array[i];
}
}
sort(part1);
sort(part2);
merge(part1,part2,array);
//for(int x=0; x<part1.length; x++)
//System.out.print(part1[x]+" ");
//for(int x=0; x<part2.length; x++)
//System.out.print(part2[x]+" ");
}
i know recursion is method(function) that call it self. im confused in this code why that program stop, when the sort() method execute and call itself sort(part1)method then the sort(part1) is executed again and again and how sort(part2) and merge(part1,part2,array) is executed, why this code is not infinite and how the program stop. sorry im new in java