Recursive Programs to find Minimum and Maximum elements of array | function to return maximum element using recursion ; if n = 0 means whole array has been traversed ; Driver Code ; Function calling
def findMaxRec ( A , n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return A [ 0 ] NEW_LINE DEDENT return max ( A [ n - 1 ] , findMaxRec ( A , n - 1 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT A = [ 1 , 4 , 45 , 6 , - 50 , 10 , 2 ] NEW_LINE n = len ( A ) NEW_LINE print ( findMaxRec ( A , n ) ) NEW_LINE DEDENT