Recursive Programs to find Minimum and Maximum elements of array | Recursive Java program to find minimum ; function to return minimum element using recursion ; if size = 0 means whole array has been traversed ; Driver code
import java . util . * ; class GFG { public static int findMinRec ( int A [ ] , int n ) { if ( n == 1 ) return A [ 0 ] ; return Math . min ( A [ n - 1 ] , findMinRec ( A , n - 1 ) ) ; } public static void main ( String args [ ] ) { int A [ ] = { 1 , 4 , 45 , 6 , - 50 , 10 , 2 } ; int n = A . length ; System . out . println ( findMinRec ( A , n ) ) ; } }