Implementing Array Algorithms FRQ Practice

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

Question 1 of 5

Cinderwick Forge stores hammer-strike counts in a nonempty int array named hits. Write highest so it returns the maximum value.

public static int highest(int[] hits) {
    /* write the method body */
}

For {4, 17, 9, 12}, state the returned value.

Question 2 of 5

Mirewick Canal records lock-gate heights in a nonempty int array named gates.

(a) Write totalHeight that returns the sum of every element. (b) Write meanHeight that returns the integer average using integer division by gates.length. (c) For {8, 10, 6}, state both results.

Question 3 of 5

Hearthwick Bakery stores loaf weights in grams in a nonempty int array named loaves.

(a) Write hasHeavy that returns true if at least one weight is 900 or more. (b) Write countLight that returns how many weights are less than 400.

For {350, 920, 410, 380}, state both return values.

Question 4 of 5

Seaglass Cove rotates shell counts one slot left. Index 0 moves to the last slot.

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

Show that {9, 3, 6, 1} becomes {3, 6, 1, 9}. Explain why index 0 must be saved before the loop that copies neighbors left.

Question 5 of 5

Ridgeline Observatory stores meteor-count samples in int[] streaks.

(a) Write reverseInPlace that reverses streaks without a second array. (b) Write dropNeighbors that returns how many consecutive pairs are strictly decreasing. (c) After reverseInPlace runs on {8, 3, 5, 2}, what does dropNeighbors return?