Consider the following code for finding a maximum element in an array: // Find a maximum element in the array A. findMax(A) findMaxHelper(A, 0, A.length) // Return the maximum element in A[left...right-1] findMaxHelper(A, left, right) if left == right - 1 return A[left] else { max1 = findMaxHelper(A, left, (right + left) / 2) max2 = findMaxHelper(A, (right + left) / 2, right) if max1 > max2 return max1 else return max2 }
Get Free Quote!
383 Experts Online