Exercise: Find the Minimum in an Array
Let's write an algorithm for finding the minimum value in an array.
We'll cover the following
Problem Statement
In this problem, you have to write a function findMin()
, which takes an array of positive integers as a parameter and returns the minimum value from it.
Sample Input
arr = [| 23, 45, 17, 10, 60, 54 |]
Sample Output
min = 60;
Coding Challenge
The skeleton of the findMin()
function is already provided, you just have to write the implementation. Think about how loops can help with this problem.
Another thing to consider is how you will keep track of the minimum value. Keep in mind that your function must return an integer.
If you feel stuck, you can always refer to the solution review in the next lesson.
Good luck!
Get hands-on with 1400+ tech skills courses.