Вы находитесь на странице: 1из 2

Jonathan F.

Quiles
II – BSIT – D
Data Structures and Algorithm
Assignment #1
• Analyze the code fragment below.
• What does the program do?
• Identify and discuss the different properties that the algorithm possess.

public class Minimum {


public static void main(String[] args) {
int a[ ] = { 23, 45, 71, 12, 87, 66, 20, 33, 15, 69 };
int min = a[0];
for (int i = 1; i < a.length; i++) {
if (a[i] < min) min = a[i];
}
System.out.println("The minimum value is: " + min);
}
}

• The code fragment show the process on how to identify the minimum values in
array using the Java programming language.
• The program is created to identify the minimum values in code fragments using
the different given in integer a[ ].

1.

➢ This the class header of the program. This part contains the title of the
code fragment. The title of the code fragment is minimum. This part serve
as the introduction of the code fragment.

2.

➢ This is the main method of the code fragment/program. This is the part
where program execution starts and stop.
3.

➢ This is the main body of the code fragment/program. This the part where
you can find the variables and formulas used in the programs. Using the
proper format you can easily create a program according to the design
and structure you desired.
➢ In this code fragment we are looking about the variables on how to solve
and get the exact minimum values of the program.
➢ We have a given value in integer a[ ] = { 23, 45, 71, 12, 87, 66, 20, 33, 15,
69 };
➢ The starting point of the integer minimum is equal to a[0];.
➢ To solve the minimum value, the code fragment use the for loops to
execute the proper solutions or formula for the programs from where for
any integer i is equal 1 and if i is less than a.length the program will add
plus one in the minimum values of the program.

4.

➢ This is the Java statement of the code fragment. It represents an action to


be carried out.
➢ This is the part where the code fragment terminate or display the output of
program using the System.out.println(“ ”);.

5.

➢ The first curly brace close the main method of the code fragment.
➢ The second curly brace end the class of code fragments.

Вам также может понравиться