Min Value

Min Value

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

Find the min value in the array or slice #

info Pseudocode for Min 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]
Min = s[length - 1]

&ldquo;Min value finding algorithm&rsquo;s visualization, bubble method&rdquo;


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


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

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


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


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