AP Computer Science A Flashcards: Implementing 2D Array Algorithms
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 10 cards to help you master important concepts.
You need to verify if every student passed an exam, with scores stored in a 2D array. What type of algorithm would you use?
You would use an algorithm that traverses the 2D array to determine if all elements have a particular property (e.g., a score >= 60).
Card 1 of 10
All Flashcards (10)
You need to verify if every student passed an exam, with scores stored in a 2D array. What type of algorithm would you use?
You would use an algorithm that traverses the 2D array to determine if all elements have a particular property (e.g., a score >= 60).
An algorithm needs to count how many items in a 2D array inventory are out of stock (quantity of 0). How would this be implemented?
The algorithm would traverse the entire 2D array and determine the number of elements having a particular property, in this case, a value of 0.
To check if a lottery ticket (represented by a 2D array of numbers) has any repeated numbers, what algorithm is needed?
An algorithm that traverses the 2D array to determine the presence or absence of duplicate elements would be required for this task.
Describe a standard algorithm for reversing the order of elements in a single row of a 2D array.
A standard algorithm would access a specific row and swap elements from opposite ends (first with last, second with second-to-last, etc.) until it reaches the middle.
What is the goal of an algorithm that accesses all consecutive pairs of elements in a 2D array row?
This algorithm aims to examine or compare adjacent elements within a row, for tasks like finding the largest change or identifying a specific sequence.
What does it mean to shift the elements in a 2D array column?
Shifting a column involves moving all elements in that column up or down by one or more positions, often wrapping the last element to the first position or vice-versa.
How does an algorithm determine if at least one element in a 2D array has a certain property?
The algorithm traverses the array and returns true as soon as it finds the first element with the property, allowing it to stop searching early.
What is a 2D array traversal?
A 2D array traversal is the process of systematically visiting each element in a 2D array, often row-by-row or column-by-column, to perform an operation.
What is a standard algorithm for computing the average of all elements in a 2D array?
A standard algorithm computes a sum by traversing all elements and then divides that sum by the total number of elements (rows * columns).
How can an algorithm find the minimum value in a specific column of a 2D array?
A standard algorithm would traverse only the elements within the designated column, comparing each element to find and store the minimum value.