Interview practice question
Deep recursion crashes with a stack overflow
Frontend Engineering · JavaScript Core · Experienced
A recursive function that processes a deeply nested tree crashes with "Maximum call stack size exceeded" on large inputs. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Stack depth limit.
- Convert to iterative with explicit stack/queue.
- Trampoline pattern.
- Validate input depth.
- Test with large inputs.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.