AP Computer Science a Flashcards: Recursion

Study Recursion in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.

QUESTION

State the recursive formula for calculating Fibonacci numbers.

Tap card or press Space to flip

ANSWER

F(n)=F(n1)+F(n2)F(n) = F(n-1) + F(n-2) with base cases F(0)=0,F(1)=1F(0)=0, F(1)=1. Each term is the sum of the two preceding terms.

1 / 40

AP Computer Science a: Data Collections

All flashcards

40 cards

What this deck covers

This deck focuses on Recursion, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science a.

How to use these flashcards

Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.

Practice questions

1 of 8Practice questions for this set
How many recursive calls are made by isPal("abba") before reaching the base case?
boolean isPal(String s) {
  if (s.length() <= 1) return true;
  if (s.charAt(0) != s.charAt(s.length()-1)) return false;
  return isPal(s.substring(1, s.length()-1));
}
```​
Choose an answer

Keep your progress across every deck

Free account · cards you mark are saved to it