Max and Min in Array Python
PROGRAM TO FIND THE MAXIMUM AND MINIMUM ELEMENT OF AN ARRAY
OUTPUT
Min of array: 1 Max of array: 1234
def
getMin(arr, n):
# If there is single element, return it.
# Else return minimum of first element
# and minimum of remaining array.
return
min
(arr);
def
getMax( arr, n):
# If there is single element, return it.
# Else return maximum of first element
# and maximum of remaining array.
return
max
(arr);
# Driver code
arr
=
[
12
,
1234
,
45
,
67
,
1
]
n
=
len
(arr)
print
(
"Minimum element of array: "
,
getMin(arr, n)); print
(
"Maximum element of array: "
,
getMax(arr, n));
Min of array: 1 Max of array: 1234
Comments
Post a Comment