114 Introduction to Computational Modeling
(a) Compare the current element with the requested value or key. If the value
of the array element satisfies the condition, store the value of the index
of the element found and terminate the search.
(b) If values are not equal, continue search.
2. If no element with value equal to the value requested is found, set the result to
value −1.
The following algorithm in pseudo-code searches the array for an element with
the requested value, kval. The algorithm outputs the index value of the element equal
to the requested (or key) value kval. If no element with value equal to the requested
value is found, the algorithm outputs a negative value.
description
This algorithm defines a linear search of array varr using