Finding Max & Min in Single Scan
Implementation for finding the maximum and minimum element in an array in a single scan itself.
Procedure :
Take array and array size (n) as input
Assign max and min variable to first element initially.
Iterate from index = 1 to n
If the element at index 1 is less than min, change min value.
If not, check if it greater than max. If so, change max value.
Contributed by Nitin Ranganath
Last updated