Finding the Index of
a Minimum Value in an Array
Sometimes we want to know where the minimum was, rather than know
its actual value.
array |
8 |
18 |
6 |
12 |
9 |
3 |
15 |
|
↑ |
↑ |
↑ |
↑ |
↑ |
↑ |
↑ |
index = 0;
1;
2;
3;
4;
5;
6;
minSoFar =
8;
6;
3;
minIndex = 0;
2;
5;
Sometimes we only want to searth through part of the array,
starting at a particular index...
Kalamazoo College