_OPTIMAL DETERMINATION OF OBJECT EXTENTS_ by by Victor J. Duvanenko, W.E. Robbins, and Ronald S. Gyurcsik [LISTINĒ ONE] /* min.c -- Procedure to find the smallest element of the array. The number of elements in the array must be > 0. ( n > 0 ) */ float find_min( array, n ) float array[]; /* input array */ int n; /* number of elements in the array ( n > 0 ) */ { register i; float min; min = array[0]; for( i = 1; i < n; i++ ) if ( min > array[i] ) min = array[i]; return( min ); } /* Procedure to find the largest element of the array. The number of elements in the array must be > 0. ( n > 0 ) */ float find_max( array, n ) float array[]; /* input array */ int n; /* number of elements in the array ( n > 0 ) */ { register i; float max; max = array[0]; for( i = 1; i < n; i++ ) if ( max < array[i] ) max = array[i]; return( max ); } [LISTING TWO] /* min_max.c -- Procedure to find the smallest and the largest element of the array. The number of elements in the array must be > 0. ( n > 0 ) */ void find_min_max( array, n, min, max ) float array[]; /* input array */ int n; /* number of elements in the array ( n > 0 ) */ float *min, *max; /* pointers to the return values */ { register i; if ( n <= 1 ) *min = *max = array[0]; else { if ( array[0] > array[1] ) { /* establish the basis min and max */ *max = array[0]; *min = array[1]; } else { *max = array[1]; *min = array[0]; } for( i = 2; ( i + 2 ) <= n; i += 2 ) if ( array[ i ] > array[ i + 1 ] ) { if ( array[ i ] > *max ) *max = array[ i ]; if ( array[ i + 1 ] < *min ) *min = array[ i + 1 ]; } else { if ( array[ i + 1 ] > *max ) *max = array[ i + 1 ]; if ( array[ i ] < *min ) *min = array[ i ]; } if ( i < n ) /* handle the odd/last array element */ if ( *max < array[i] ) *max = array[i]; else if ( *min > array[i] ) *min = array[i]; } }