APCSP Computational Thinking Practices 3 — Questions and Answers
Question 1: A student writes an algorithm that works correctly on small inputs but fails on inputs with 10,000 elements. What should she do next according to computational thinking practices?
- Rewrite the entire program from scratch
- Analyze the algorithm's efficiency and identify bottlenecks (Correct answer)
- Reduce the input size permanently
- Switch to a different programming language
Correct answer: Analyze the algorithm's efficiency and identify bottlenecks
Analyzing efficiency and identifying bottlenecks is part of evaluating and refining algorithms, a core computational thinking practice.
Question 2: Which of the following is the BEST example of using abstraction when designing a navigation app?
- Storing every road intersection as a separate variable
- Representing roads as edges and intersections as nodes in a graph, ignoring irrelevant details like road color (Correct answer)
- Drawing a photorealistic map of each city
- Using a different data structure for every city
Correct answer: Representing roads as edges and intersections as nodes in a graph, ignoring irrelevant details like road color
Representing roads and intersections as a graph while ignoring irrelevant details (like road color) is a classic use of abstraction.
Question 3: A programmer uses a function called `calculate_area()` in her code without knowing how it works internally. Which principle does this illustrate?
- Iteration
- Procedural abstraction (Correct answer)
- Recursion
- Heuristics
Correct answer: Procedural abstraction
Procedural abstraction allows a programmer to use a function based on what it does, without needing to know how it is implemented.
Question 4: Which of the following is a key benefit of using pseudocode during the problem-solving phase?
- It runs faster than compiled code
- It allows the programmer to focus on logic without worrying about syntax (Correct answer)
- It automatically generates test cases
- It eliminates the need for debugging
Correct answer: It allows the programmer to focus on logic without worrying about syntax
Pseudocode lets a programmer express algorithmic logic in plain language, separating problem-solving from the constraints of a specific language's syntax.
Question 5: A student claims her image compression program is correct because it worked on the three test images she tried. What is the flaw in her reasoning?
- Three test images is always sufficient for any program
- A small test set may not cover all edge cases and input types (Correct answer)
- Image compression programs cannot be tested with real images
- She should have used a different programming language
Correct answer: A small test set may not cover all edge cases and input types
Testing with only a few samples may miss edge cases like very large images, all-black images, or unusual formats, leaving bugs undetected.
Question 6: In computational thinking, what does it mean to 'generalize' a solution?
- Make the solution work only for a specific input
- Adapt a solution so it works for a broader class of problems (Correct answer)
- Remove all loops from the code
- Increase the number of variables used
Correct answer: Adapt a solution so it works for a broader class of problems
Generalizing means extending a solution beyond the specific case it was designed for so it applies to a wider range of similar problems.
Question 7: Which of the following would be the FIRST step in the computational thinking process when approached with a new complex problem?
- Write code immediately in a preferred language
- Test the solution with sample data
- Understand and define the problem clearly (Correct answer)
- Optimize the algorithm for speed
Correct answer: Understand and define the problem clearly
Before writing code or testing, a computational thinker must clearly understand and define the problem to know what needs to be solved.
A student writes an algorithm that works correctly on small inputs but fails on inputs with 10,000 elements.
What should she do next according to computational thinking practices?