fbpx
//Java program to find minimum array element using recursion

class ArrayClsMin
{
    public int arrMin(int Arr[],int n)
    {
        if(n == 1)
        {
           return Arr[0];
        }
        return Math.min(Arr[n-1],arrMin(Arr,n-1));
    }
}
public class ArrayRec
{
    public static void main(String args[])
    {
        ArrayClsMin obj=new ArrayClsMin();
        int Arr[] = {12, -53, 44, 46, -45, 35, 27};
        int n = Arr.length;
        System.out.println("Minimum Element: "+obj.arrMin(Arr,n));
    }
}
– For more java recursion tutorial contact : 9173040728

Leave a Reply

×