AP Computer Science A 50 Flashcards Advanced 100% Free

AP Computer Science A:: Recursion

Created by Chat Robotics Community  ·  Updated 2026-08-31

Curriculum Overview

Comprehensive, high-yield AP Computer Science A study deck focusing on Recursion. Features 50 rigorous, curriculum-aligned flashcards designed for advanced-level mastery. Core concepts covered include Recursion, key problem-solving heuristics, foundational formulas, and exam-tested application scenarios. Ideal for active recall review, spaced repetition study, and scoring in the top percentile.

Topics & Key Concepts

BASE CASE This Unit BEFORE String Science Computer RECURSIVE Recursion

Sample Flashcard Questions & Answers

Showing 8 of 50 cards
Question #1 Active Recall

What is a RECURSIVE method?

- **A)** A method that calls ITSELF, either directly or indirectly, as part of its own execution
- **B)** A synonym for a method with no parameters
- **C)** A method that always runs exactly once and then never again
- **D)** A method that can never call any other method

Answer & Explanation:
**Answer: A)**

Recursion is defined by a method invoking itself, typically to break a problem down into smaller versions of the same problem.
Question #2 Active Recall

What is a BASE CASE in a recursive method, and why is it essential?

- **A)** A synonym for a recursive method's parameter list
- **B)** The very FIRST time a recursive method is ever called
- **C)** A base case is optional and can safely be omitted from any recursive method
- **D)** A condition under which the method STOPS calling itself and returns a result DIRECTLY, without further recursion -- without a base case, a recursive method would call itself FOREVER, leading to infinite recursion

Answer & Explanation:
**Answer: D)**

The base case is the essential 'stopping condition' that prevents infinite recursion -- every properly written recursive method must have at least one.
Question #3 Active Recall

What is the RECURSIVE CASE in a recursive method?

- **A)** The recursive case is only relevant to loops, not recursive methods
- **B)** A synonym for the base case
- **C)** A case that never actually involves calling the method again
- **D)** The part of the method where it CALLS ITSELF, typically with a SMALLER or SIMPLER version of the original problem, making progress toward eventually reaching the base case

Answer & Explanation:
**Answer: D)**

The recursive case is where the actual self-call happens, and must move the problem CLOSER to the base case each time to guarantee eventual termination.
Question #4 Active Recall

Given \(int\ factorial(int\ n)\ \{\ if\ (n\ ==\ 0)\ \{\ return\ 1;\ \}\ else\ \{\ return\ n\ *\ factorial(n\ -\ 1);\ \}\ \}\), what is the BASE CASE of this method?

- **A)** This method has no base case at all
- **B)** The entire method is a base case with no recursive part
- **C)** \(n\ ==\ 0\), which returns \(1\) directly without any further recursive call
- **D)** \(n\ *\ factorial(n - 1)\), the recursive call itself

Answer & Explanation:
**Answer: C)**

The \(n == 0\) condition is the stopping point: once reached, the method returns \(1\) immediately without recursing further.
Question #5 Active Recall

What would happen if the \(factorial\) method's BASE CASE (\(n\ ==\ 0\)) were REMOVED entirely, leaving only the recursive case?

- **A)** This would cause a compile-time error
- **B)** INFINITE RECURSION would occur -- the method would keep calling itself with smaller and smaller values of \(n\) forever (going negative, since nothing stops it), eventually causing a \(StackOverflowError\)
- **C)** The method would return \(0\) immediately
- **D)** The method would work exactly the same as before, with no functional difference

Answer & Explanation:
**Answer: B)**

Removing the base case eliminates the only thing preventing endless recursive calls, eventually exhausting the call stack and causing a runtime \(StackOverflowError\).
Question #6 Active Recall

What is a \(StackOverflowError\), and what commonly causes it in the context of recursion?

- **A)** \(StackOverflowError\) indicates the program finished successfully
- **B)** A compile-time error indicating a syntax mistake
- **C)** A runtime error that occurs when TOO MANY method calls are stacked up without returning (e.g., from missing or incorrect base cases causing excessive or infinite recursion), exhausting the memory reserved for tracking active method calls
- **D)** An error that only occurs in loops, never in recursive methods

Answer & Explanation:
**Answer: C)**

\(StackOverflowError\) is the concrete, real consequence of recursion that never reaches its base case (or takes too many steps to do so).
Question #7 Active Recall

Trace through \(factorial(4)\) using \(int\ factorial(int\ n)\ \{\ if\ (n\ ==\ 0)\ \{\ return\ 1;\ \}\ else\ \{\ return\ n\ *\ factorial(n\ -\ 1);\ \}\ \}\). What value does it return?

- **A)** \(4\)
- **B)** \(10\)
- **C)** \(24\), since \(4! = 4 \times 3 \times 2 \times 1 \times 1 = 24\)
- **D)** \(0\)

Answer & Explanation:
**Answer: C)**

\(factorial(4)\) computes \(4 \times factorial(3)\), which unwinds down to \(4 \times 3 \times 2 \times 1 \times factorial(0)=1\), giving 24.
Question #8 Active Recall

What is the general STRATEGY behind recursion for solving a problem?

- **A)** Solve the entire problem in a single step with no sub-problems involved at all
- **B)** Break the ORIGINAL problem down into ONE OR MORE SMALLER, SIMPLER versions of the SAME problem, solve those smaller versions (often via further recursive calls), and then COMBINE their results to solve the original problem
- **C)** Recursion always requires solving a completely unrelated, different problem first
- **D)** Recursion strategy is identical to writing a single \(if\) statement with no repetition of any kind

Answer & Explanation:
**Answer: B)**

This 'divide into smaller versions of the same problem' strategy is the conceptual heart of recursive problem-solving.

Want to study all 50 flashcards with spaced repetition?

Practice with Anki-style scheduling, Hands-Free audio commute mode, and AI Tutor explanations.

Start Studying Full Deck Now

How You Can Study This Deck on Chat Robotics

Anki Spaced Repetition (SRS)

Algorithms schedule review intervals automatically so you retain 90%+ in minimum study time.

Hands-Free Audio Commute Mode

High-fidelity Neural Text-To-Speech reads questions and answers aloud with customizable delay timers.

Built-in AI Tutor Assistant

Stuck on a tricky concept? Click "Ask AI" on any card to receive instant deep-dive step-by-step explanations.

Subdeck & Tag Organization

Organize and filter by topic tags or drill entire subdeck hierarchies sequentially in Subdeck Scheduler.