Recursion
AP Computer Science A · Flashcards
AP COMPUTER SCIENCE A · FLASHCARDS
Card 1
of 40
0 got it
0 to review
Current
Got it
Still learning
Not seen
QUESTION
Identify the recursive call in the function: int sum(int n) { if (n<=0) return 0; else return n+sum(n-1); }
QUESTION
Which option best describes the stack overflow error in recursion?
QUESTION
State the recursive formula for calculating Fibonacci numbers.
Tap to flip before you grade
ANSWER
F
(
n
)
=
F
(
n
−
1
)
+
F
(
n
−
2
)
F(n) = F(n-1) + F(n-2)
F
(
n
)
=
F
(
n
−
1
)
+
F
(
n
−
2
)
with base cases
F
(
0
)
=
0
,
F
(
1
)
=
1
F(0)=0, F(1)=1
F
(
0
)
=
0
,
F
(
1
)
=
1
. Each term is the sum of the two preceding terms.
Swipe → got it · swipe ← still learning
Got it
Still learning
Flip Card
Previous card
Next card