← All APCSP Flashcard Decks

Algorithms and Programming Flashcards

7 cards from real APCSP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 7 Algorithms and Programming flashcards as text
  1. A function receives a list of numbers and returns their average. If the list is empty, the function crashes. What is this an example of?

    Answer: Failing to handle an edge case

    An empty list is an edge case — a boundary condition the programmer failed to anticipate and handle gracefully.

  2. Which of the following correctly describes the difference between a parameter and an argument?

    Answer: A parameter is a variable in the procedure definition; an argument is the value passed when calling it

    Parameters are placeholder variables defined in the procedure header; arguments are the actual values supplied when the procedure is called.

  3. What does it mean for an algorithm to run in polynomial time?

    Answer: The number of steps grows as a polynomial function of the input size

    Polynomial time means the number of operations is bounded by a polynomial expression (like n, n², n³) in terms of the input size n.

  4. A robot moves forward, turns right, and repeats this sequence 4 times. What shape does its path form?

    Answer: Square

    Repeating 'move forward, turn right 90°' four times traces a square path.

  5. Which of the following is the best reason to use a library or API in a program?

    Answer: To reuse existing, tested code and avoid reimplementing common functionality

    Libraries and APIs provide reusable, pre-tested functionality so programmers don't need to rewrite common operations from scratch.

  6. Consider this pseudocode: x ← 10 IF x > 5 THEN x ← x + 1 ELSE x ← x - 1 What is the final value of x?

    Answer: 11

    Since 10 > 5 is TRUE, the THEN branch executes: x becomes 10 + 1 = 11.

  7. In AP CSP pseudocode, what is the purpose of the APPEND procedure when working with lists?

    Answer: It adds a new element to the end of a list

    APPEND(list, value) adds the specified value to the end of the list, increasing its length by one.