function findMax(arr):
max = arr[0]
for i from 1 to arr.length - 1:
if arr[i] > max:
max = arr[i]
return max
One loop. n iterations. O(n) time complexity.
(Implementation structure)
function findMax(arr):
max = arr[0]
for i from 1 to arr.length - 1:
if arr[i] > max:
max = arr[i]
return max
One loop. n iterations. O(n) time complexity.