This concept helps manage complexity by grouping related data into a single structure.
What is DATA ABSTRACTION?
Given primes ← [2, 3, 5, 7, 11], DISPLAY(primes[LENGTH(primes)]) shows this value.
What is 11?
This operation adds an element to the end of a list.
What is APPEND(list, value)?
This operator returns the remainder and is used to check odd/even numbers.
What is MOD?
This keyword sends a value back to the caller (HINT: think of the reporter block).
What is RETURN?
What will be displayed when this program runs?
primes <- [1, 5, 7, 11, 13]
DISPLAY(primes[LENGTH(primes)])
What is 5?
Using a list instead of separate variables makes this easier when processing data.
What is ITERATION?
In AP CSP pseudocode, list indexing starts at this value.
What is 1?
What is the result of INSERT(letters, 1, "A") when letters ← ["B", "C"]?
What is ["A", "B", "C"]?
Fill in the condition to test if n is odd: IF ( ______ ).
What is n MOD 2 = 1?
In an average-calculating procedure, RETURN total/size belongs here.
What is after the loop but before the end of the procedure?
What change can be made so that the procedure will work?
PROCEDURE countNumOccurances(myList, val)
{
FOR EACH item IN myLIST
{
count <- 10
IF(item = val)
{
count <- count - 1
}
}
RETURN(count)
}
What is change line 5 to be between line 2 and 3?
Two lists that store related data at matching indexes are called this.
What are PARALLEL LISTS?
Fill in the stop condition: REPEAT UNTIL ( ______ ) to print all elements when index starts at 1.
What is index = LENGTH(list) + 1?
After REMOVE(folks, 1) and APPEND(folks, "Mary") on ["Peter","Paul","Mary"], what is folks?
What is ["Paul","Mary","Mary"]?
To count multiples of 3, fill in: IF ( ______ ).
What is number MOD 3 = 0?
Placing RETURN sum inside the loop causes this incorrect behavior.
What is returning early after the first iteration?
This procedure calculates the overall average of all grades in a nested list of students and their scores. It requires two loops: one for students and one for their grades. What is the correct approach to compute the average?
What is summing all grades and dividing by the total count of grades using nested loops?
DAILY DOUBLE: You need to store each student’s name and all their quiz scores together. Name one valid list-based design.
What is a nested list or list of pairs?
DAILY DOUBLE: pets ← ["dog", "cat", "fish", "bird"]. What does DISPLAY(pets[LENGTH(pets) - 1]) show?
What is "fish"?
DAILY DOUBLE:
Avengers <- ["Captain America", "Hulk", "IronMan", "Black Widow", "Hawkeye"]
APPEND(Avengers, "Thor")
REMOVE(Avengers, 1)
INSERT(Avengers, 1, Spiderman)
Display(Avengers, 2)
What is "Hulk"?
DAILY DOUBLE: To track the smallest value while traversing grades, complete: IF ( ______ ).
What is g < lowest?
DAILY DOUBLE: Given mystery([10,6,5,12],3,9), what is the returned list?
What is [30,9,15,9]?
This control structure is required when an algorithm must examine every element in a list and selectively add only those that meet a condition, such as students earning honor roll status.
What is a loop with a conditional (iteration + selection)?
Creating a reusable procedure like checkVitals(patient) is an example of this abstraction.
What is procedural abstraction?
For a list of length 8, a loop that increments i by 2 starting at 2 displays these positions.
What are 2, 4, 6, and 8?
Removing elements while looping forward through a list causes this bug.
What is skipping elements due to index shifting?
Given nums ← [21, 4, 10, 15, 30, 7], counting number MOD 5 = 0 gives this result.
What is 3?
In findMaxNumber, when number > maximum, this assignment updates the tracker.
What is maximum ← number?
This expression correctly accesses the last element of a list in AP CSP pseudocode, regardless of the list's size.
What is list[length(list)]?