We can easily modify some divide and conquer algorithms. For example, the following pseudocode finds the maximum value of an array:
function maximum(array, start, end):
if start == end then:
return array[start]
mid = int((start + end) / 2)
left = maximum(array, start, mid)
right = maximum(array, mid + 1, end)
if left > right then:
return left
else:
return rightHere function returns the largest integer less than the given number, i.e. for example, will return 4.
By modifying one line of the pseudocode, you can use it to find the minimum value of an array. Please mention the line number below: