Description
A worksheet that allows students to practice a common AP Computer Science exam question: finding the maximum and minimum values in an array using a linear search. Includes fully coded answer!
Example:
Write methods to find the maximum and minimum values in an array and return the indices at which they occur. If the array length is zero, return -1.
int[] arr = {10, 3, 85, 2, 9, 14, 11};
int index = arrayMax(arr);
System.out.println(“Max value “ + arr[index] + “ found at index “ + index);
>> Element 85 found at index 2
Highlights
Description
A worksheet that allows students to practice a common AP Computer Science exam question: finding the maximum and minimum values in an array using a linear search. Includes fully coded answer!
Example:
Write methods to find the maximum and minimum values in an array and return the indices at which they occur. If the array length is zero, return -1.
int[] arr = {10, 3, 85, 2, 9, 14, 11};
int index = arrayMax(arr);
System.out.println(“Max value “ + arr[index] + “ found at index “ + index);
>> Element 85 found at index 2


