go to previous page   go to home page   go to next page

Answer:

Yes.

Finding the minimum in an Array

Here is a program that finds the minimum of an array. It is similar to the maximum-finding program:

class MinAlgorithm
{

  public static void main ( String[] args ) 
  {

    int[] array =  { -20, 19, 1, 5, -1, 27, 19, 5 } ;
    int   min;

    // initialize the current minimum
    min =  ;

    // scan the array
    for ( int index=0; index < array.length; index++ )
    { 
      if  ;

         ;

    }
      
    System.out.println("The minimum of this array is: " + min );
  }
}      

QUESTION 15:

Fill in the blanks. Select from the following phrases.

array[8]
array[0]
array[ index ]
> min
< min
min =
index++

(Hint: only some of the phrases are used.)