Area of Improvements

Review your assessments and practice — drill into each subject, then each attempt, then each question.

Back to summary
C Programming · Round 1

Question 8 of 10

Topic: OperatorsDifficulty: EasyBloom: Evaluate
Question

When would you NOT use recursion in C? Give a concrete example.

Result
Knowledge
72%
Delivery
80%
Technical relevancy
75%
Technical term match
68%
Your recording
Your transcript

If the recursion is really deep you shouldn't, because of stack overflow. Like computing factorial of a million would crash. You'd use a loop instead.

Better answer

Avoid recursion when depth is unbounded or large relative to the stack (typically a few MB), when the compiler cannot apply tail-call optimisation (C compilers don't guarantee it), or when each frame is heavy. Example: traversing a linked list of a million nodes recursively will stack-overflow; an iterative loop runs in O(1) stack space.

Coverage
Hit 3 of 4
  • Identifies stack-overflow risk on deep recursion
  • Gives a concrete example (large list / large n)
  • Mentions C does not guarantee tail-call optimisation
  • Recommends iterative alternative
Gaps
  • Did not mention lack of guaranteed TCO in C
Misconceptions
  • Implied modern compilers always optimise tail calls