Prévia do material em texto
Chapter 1.2, Problem 2E Step-by-step solution Step 1 of 1 Find the smallest value in an array using for loop Consider an array of n integers. Traverse the array and keep track of the smallest value in the traversed array. As we move further and if we find the value smaller than that in traversed array we will update our smallest value. Here Input parameter: (array of integers) and Output parameter: the smallest value in array. Algorithm: find the smallest value in the array array_min(s) small =s [1] //will assigns first value to small i = 2 for i = 2to s.last //traverse up to end of an array if (s[i]