Program to find the minimum ( or maximum ) element of an array | Python3 program to find minimum ( or maximum ) element in an array . ; If there is single element , return it . Else return minimum of first element and minimum of remaining array . ; If there is single element , return it . Else return maximum of first element and maximum of remaining array . ; Driver code
def getMin ( arr , n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return arr [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT return min ( getMin ( arr [ 1 : ] , n - 1 ) , arr [ 0 ] ) NEW_LINE DEDENT DEDENT def getMax ( arr , n ) : NEW_LINE INDENT if ( n == 1 ) : NEW_LINE INDENT return arr [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT return max ( getMax ( arr [ 1 : ] , n - 1 ) , arr [ 0 ] ) NEW_LINE DEDENT DEDENT arr = [ 12 , 1234 , 45 , 67 , 1 ] NEW_LINE n = len ( arr ) NEW_LINE print ( " Minimum ▁ element ▁ of ▁ array : ▁ " , getMin ( arr , n ) ) ; NEW_LINE print ( " Maximum ▁ element ▁ of ▁ array : ▁ " , getMax ( arr , n ) ) ; NEW_LINE