PrepGo

AP Computer Science Principles Flashcards: Lists

Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026

Review key ideas with interactive flashcards. This set includes 19 cards to help you master important concepts.

What programming structure is used to traverse a list?
Iteration statements, such as the FOR EACH loop provided on the exam reference sheet, are used to traverse a list.
Card 1 of 19

All Flashcards (19)

What programming structure is used to traverse a list?
Iteration statements, such as the FOR EACH loop provided on the exam reference sheet, are used to traverse a list.
What is the purpose of a list procedure?
A list procedure is a defined operation, like inserting or removing an element, that can be performed on a list according to the programming language's syntax rules.
Name four basic list operations available on the exam reference sheet.
Four operations are: accessing an element by index, inserting an element, removing an element, and determining the length of the list.
What is a linear search algorithm?
A linear (or sequential) search is an algorithm that checks each element of a list in order until a target value is found or until all elements have been checked.
What is the purpose of the `FOR EACH` loop structure on the exam reference sheet?
The `FOR EACH` loop is provided on the exam reference sheet as a standard structure for iterating over all elements of a list.
What is the result of an algorithm that traverses the list [10, 20, 30] to compute the sum?
The algorithm would traverse the list and add each element, resulting in a final sum of 60.
What is list indexing?
List indexing is the process of accessing a specific element in a list by its position or index number.
What does the `APPEND` list procedure do?
The `APPEND` procedure adds a new element to the very end of an existing list, increasing the list's length by one.
How does understanding an algorithm for computing a sum help in creating one for computing an average?
Knowledge of the iteration pattern for a sum provides the foundation for a new algorithm, which simply adds the step of tracking the list's length.
What does the `REMOVE` list procedure do?
The `REMOVE` procedure deletes an element from a list at a specified index, shortening the list and shifting subsequent elements.
What does it mean to traverse a list?
Traversing a list means accessing the elements of the list, usually one at a time in sequence, often to perform some operation on each element.
Write a general expression to access the last element of a list named `data`.
The expression would use the list's length, typically as `data[LENGTH(data) - 1]` for 0-indexed lists or `data[LENGTH(data)]` for 1-indexed lists.
When performing a linear search, what is the worst-case outcome?
The worst-case outcome for a linear search is when the target value is not in the list, forcing the algorithm to check every single element.
How can an iteration statement be used to find the minimum value in a list?
An iteration statement can traverse the list, comparing each element to a variable holding the current minimum, and updating that variable whenever a smaller element is found.
Why must list procedures follow the syntax rules of the programming language?
List procedures must be implemented in accordance with syntax rules so the computer can correctly interpret and execute the intended operation without errors.
Differentiate between a complete traversal and a partial traversal.
A complete traversal accesses every single element in a list, whereas a partial traversal only accesses a specific portion or subset of the elements.
What is the difference between assigning a value TO an element and assigning an element TO a variable?
Assigning a value to an element (e.g., list[i] = 5) modifies the list itself. Assigning an element to a variable (e.g., x = list[i]) copies the element's value into the variable.
To compute the average of a list of numbers, what two results must an algorithm determine?
The algorithm must determine the sum of all elements in the list and the total number of elements (the length of the list).
What does the `INSERT` list procedure do?
The `INSERT` procedure adds a new element to a list at a specified index, shifting subsequent elements to make room.