Exercise 2

1 Using Algorithm Sections

Write a class, FindSmallest, that finds the value and position of the smallest element in an arbitrary array.




Write a class that makes an instance of the
FindSmallest class and give the array values.



1.1

1.1.1 FindSmallest

Loop through all elements in the array except the first. The smallest value is initially the first value in the array.



1.1.2 FindSmallestElement


1.1.3 Simulation of FindSmallestElement


Here we can see that the smallest value in the array is the element in position 5 with the value 2.