Linear Search

Linear Search

Linear Search is an algorithm used to find an element position in the collection. It compares each element to the searched value consecutively and returns the position when it is found.

Linear search algorithm #

info Pseudocode for Linear Search algorithm
ITERATE over the list s
    IF s[i] == value THEN
        return i

Found position = i

“Linear search algorithm’s visualization”

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

Searched Value: 4
Slice: [3 1 4 2]
4 is located at the position: 2