0%
0 / 25 answered
Practice Test 2
•25 QuestionsQuestion
1 / 25
Q1
A method finds the smallest value in an int[] of size $n$.
public static int minValue(int[] nums) {
int min = nums<u>0</u>;
for (int i = 1; i < nums.length; i++) {
if (nums<u>i</u> < min) {
min = nums<u>i</u>;
}
}
return min;
}
What is the run-time complexity of the algorithm in the code snippet?
A method finds the smallest value in an int[] of size $n$.
public static int minValue(int[] nums) {
int min = nums<u>0</u>;
for (int i = 1; i < nums.length; i++) {
if (nums<u>i</u> < min) {
min = nums<u>i</u>;
}
}
return min;
}
What is the run-time complexity of the algorithm in the code snippet?