Content deleted Content added
removed repetitions of "following it" and "preceding it" |
-wikicode |
||
Line 7:
Worst-case linear algorithms to find minimums or maximums are obvious; we keep two variables, one referring to the index of the minimum/maximum element seen so far, and one holding its value. As we scan through the list, we update these whenever we encounter a more extreme element:
'''function''' minimum(a[1..n])
minIndex := 1
|