Math Fundamentals18 sections · 814 units
Open in Course

Find Maximum - Algorithm

(Loop and compare)

1.1. Start with max = arr[0]

2.2. For each remaining element x: if x > max, set max = x

3.3. Return max

You do n-1 comparisons. This is O(n).