Back to Topic 6.4 — Programming algorithms
6.4.4Computer Science5 flashcards

Recursion

Practice Flashcards

Flip to reveal answers
Card 1 of 56.4.4
6.4.4
Question

What are the two parts of a recursive function?

Click to reveal answer

Track your progress — Sign up free to save your progress and get smart review reminders based on spaced repetition.

All 5 Flashcards — Recursion

Sign up free to track progress and get spaced-repetition review schedules.

Card 1definition

Question

What are the two parts of a recursive function?

Answer

A **base case** that returns without recursing, and a **recursive case** that calls itself on a smaller problem.

Card 2concept

Question

Why does deep recursion cause a stack overflow?

Answer

Each call keeps a **stack frame** — parameters, locals, return address — and none is released until the base case is reached.

Card 3concept

Question

Why do recursive calls need a stack?

Answer

They return in the **reverse order** they were made, most recent first — last in, first out.

Card 4comparison

Question

When is recursion genuinely better than iteration?

Answer

When the **data is self-similar** — a tree, a folder structure, a nested expression. Iterating those needs an explicit stack managed by hand.

Card 5concept

Question

Is recursive factorial a good choice?

Answer

It is a good **teaching example**, not a good choice — a loop is faster and uses constant memory.

Track your progress with spaced repetition

Sign up free — Aimnova tells you exactly which cards to review and when, so you remember everything before your IB exam.

Start Free