Max Value

Max Value

Max Value algorithm finds the biggest value in the list. There are various methods to do this, and a few ways of finding the biggest element in the array is described here.

Find the max value in the array or slice #

info Pseudocode for Max Value algorithm (bubble method)
ITERATE over the list s UNTIL s[length - 1]
    IF s[i] > s[i+1] THEN
        swap s[i] with s[i+1]
Max = s[length - 1]

“Max value finding algorithm’s visualization, bubble method”


------ Execution ------


Slice (before): [3 1 4 2]
Max Value = 4
Slice (after): [1 3 2 4]
info Pseudocode for Max Value algorithm (save method)
ITERATE over the list s
    SAVE s[0] as maxVal
    IF maxVal < s[i] THEN
        SAVE s[i] as a new maxVal
Max = maxVal

&ldquo;Max value finding algorithm&rsquo;s visualization, save method&rdquo;


------ Execution ------


Slice (before): [3 1 4 2]
Max Value = 4
Slice (after): [3 1 4 2]