Implementing Array Algorithms FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Frostwick Arena stores ice-show scores in a nonempty one-dimensional int array named scores. Write the method lowest that returns the minimum score.

public static int lowest(int[] scores) {
    /* write the method body */
}

The table shows one sample array. State the value lowest must return for that sample.

Index Score
0 16
1 9
2 14
3 11

Question 2 of 5

Claywick Lane reverses glaze-batch numbers in place.

int[] glaze = {2, 8, 5, 1};
for (int i = 0; i < glaze.length / 2; i++) {
    int temp = glaze[i];
    glaze[i] = glaze[glaze.length - 1 - i];
    glaze[glaze.length - 1 - i] = temp;
}

(a) After the loop, list the four values in index order. (b) Write a method reverse that performs this in-place reverse for any nonempty int array batches.

Question 3 of 5

Ironwick Docks rotate crane-load values one slot to the right. The last load moves into index 0.

public static void rotateRight(int[] loads) {
    /* write the method body */
}

(a) Write rotateRight so that {7, 4, 9, 2} becomes {2, 7, 4, 9}. (b) Explain why the last value must be saved before the shifting loop starts.

Question 4 of 5

Hymnwick Hall records choir volume samples in a nonempty int array named levels.

(a) Write countLoud(int[] levels) that returns how many values are greater than 40. (b) Write allPositive(int[] levels) that returns true only when every value is greater than 0.

Question 5 of 5

Gale Wick Ridge stores kite-line tensions. Write two short methods that use only the given 1D array.

public static int risingNeighbors(int[] pull) { /* consecutive pairs */ }
public static boolean hasDuplicate(int[] pull) { /* any two matching values */ }

risingNeighbors returns how many times a value is followed immediately by a strictly larger value. hasDuplicate returns true if any value appears more than once, including non-adjacent copies. For {3, 5, 5, 8, 2}, state both return values.