MIS 24053 Lecture Notes - Lecture 25: Gold Base
Document Summary
Find the smallest value in a list of integers. A list of integers and a value indicating the number of integers. List remains unchanged after finding the smallest value! When looking for value with distinguishing characteristics, need a way of remembering best candidate found so far. Best written as a function - likely to be used often. Use a loop to consider each element in turn. If current element is smallest so far, then update smallest value so far candidate. When done examining all of the elements, the smallest value seen so far is the smallest value. Array with values to be inspected for smallest value. Function that takes two parameters: an integer array and the array size; returns smallest value. For each of the other elements in the array. If it is smaller than the smallest value so far, update the value of the smallest value so far to current element.