?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Elevation Comparison Using an Array

APCSA-DETPT8

Consider the following code segment.

int[] elevation = {50, 20, 4, 29, 72, 10, 65, 2, 32};
int m = Integer.MAX_VALUE; 
int p = Integer.MIN_VALUE; 

for (int i=0; i<elevation.length/2; i++)
{
    if(elevation[i]<m)
        m=elevation[i];
    if(elevation[i]>p)
        p=elevation[i];
}

for int i=elevation.length/2; i<elevation.length; i++)
{
    if(elevation[i]>m && elevation[i]<p)
        System.out.print(elevation[i] + " ");
}

What is the output from the segment of code, which is comparing elevation levels?

A

72 10 65 2 32

B

10 32

C

20 29 10 32

D

10 65 32

E

50 20 4 29 10 65 32