Algorithm arrayMax(A, n):
Input: An array A storing n ≥ 1 integers.
Output: The maximum element in A.
currentMax ← A[0]
for i ← 1 to n − 1 do
if currentMax < A[i] then
currentMax ← A[i]
return currentMax - Define a function that takes the array/list as an argument
findArrayMax(input) - Set the first member of the array to a variable
currentMax = input[0] - Loop through the array and compare each value of the array with the initialized variable to determine the one with the higher value.
- Set the higher value to the variable
- Return the maximum value in the array
return currentMax