Algorithm of Finding Maximum and Minimum Element From An Array
This algorithm finds the maximum and minimum elements in an array. It recursively finds the max and min of the left and right halves if the array contains more than 2 elements. Otherwise, it directly compares the 1 or 2 elements to determine the max and min. It returns the pair containing the true maximum and minimum elements after comparing the candidates from each half.
Download as ODT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
32 views
Algorithm of Finding Maximum and Minimum Element From An Array
This algorithm finds the maximum and minimum elements in an array. It recursively finds the max and min of the left and right halves if the array contains more than 2 elements. Otherwise, it directly compares the 1 or 2 elements to determine the max and min. It returns the pair containing the true maximum and minimum elements after comparing the candidates from each half.
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 1
ALGORITHM OF FINDING MAXIMUM AND MINIMUM
ELEMENT FROM AN ARRAY
MaxMin(array, array_size) if array_size = 1 return element as both max and min else if arry_size = 2 one comparison to determine max and min return that pair else /* array_size > 2 */ recur for max and min of left half recur for max and min of right half one comparison determines true max of the two candidates one comparison determines true min of the two candidates return the pair of max and min