Prévia do material em texto
Chapter 1.2, Problem 1E Step-by-step solution Step 1 of 1 Find the smallest value in an array using while 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 is (array of integers) and Output parameter is the smallest value in array. Algorithm: find the smallest value in the array using while loop. array_min(s) small =s[1] = //will assigns first value to small i = 2 while //traverse up to end of an array if //smaller value found small = s[i] //new small } return small }