Questions
10 of 29
1Explain the difference between an in-place algorithm and an out-of-place algorithm.
2What are the risks of using Recursion? (Stack Overflow, Exponential Time)
3Explain the difference between a Data Structure and an Abstract Data Type (ADT).
4What is Time Complexity? How is it different from Space Complexity?
5What is Amortized Analysis? When is it used? (Hint: Dynamic Arrays)
6Explain Big-O notation. What do O(1), O(n), O(log n), O(n log n), O(n²) mean?
7Rank the common Big-O complexities from best to worst.
8Explain Memoization. How does it optimize recursive solutions?
9What is the difference between Best Case, Average Case, and Worst Case complexity?
10What is Recursion? How does it relate to the Call Stack?
11What are the risks of using Recursion? (Stack Overflow, Exponential Time)
12Explain the difference between an in-place algorithm and an out-of-place algorithm.
13Explain Memoization. How does it optimize recursive solutions?
14What is Amortized Analysis? When is it used? (Hint: Dynamic Arrays)
15Explain Big-O notation. What does O(1), O(n), O(log n), O(n log n), O(n^2) mean?
16Explain the difference between a Data Structure and an Abstract Data Type (ADT).
17What is Time Complexity? How is it different from Space Complexity?
18Rank the common Big-O complexities from best to worst.
19What is the difference between Static and Dynamic Data Structures?
20What is Recursion? How does it relate to the Call Stack?
21What is the Master Theorem? When can it be applied?
22What is the difference between Static and Dynamic Data Structures?
23What is the Master Theorem? When can it be applied?
24What is the difference between Best Case, Average Case, and Worst Case complexity?
25What is the difference between Linear Data Structures and Non-Linear Data Structures?
26What is a stable algorithm? Why does stability matter in sorting?
27What is the difference between Linear Data Structures and Non-Linear Data Structures?
28What is a Data Structure? Why do we need them?
29What is a stable algorithm? Why does stability matter in sorting?
10 / 29

What is Recursion? How does it relate to the Call Stack?

Difficulty: 5/10
base case, stack overflow, tail recursion

Recursion and Call Stack

Recursion is a technique in which a function calls itself to solve a problem by reducing it to smaller instances of the same problem. A recursive solution requires a base case to terminate the recursion.

javascript

Each recursive call creates a new stack frame containing local variables, parameters, and the return address. These frames remain on the call stack until the recursive calls return. Excessive recursion can therefore cause stack overflow.

  1. 1

    Every recursive solution needs a termination condition.

  2. 2

    Each call creates a call-stack frame.

  3. 3

    Recursive calls are unwound in reverse order.

  4. 4

    Deep recursion can cause stack overflow.

  5. 5

    Many recursive algorithms can be converted into iterative solutions.

Scenario Questions

0-2 years experience

  1. 1Write a function to compute the nth Fibonacci number using recursion. How does the call stack evolve with each call?
  2. 2Given a binary tree node class, how would you implement a recursive in‑order traversal, and what does the stack look like during the traversal?

2-5 years experience

  1. 1We added a recursive parser for nested JSON objects, but it crashes with a stack overflow on deep inputs. How would you diagnose and fix the issue?
  2. 2We need to refactor a recursive depth‑first search into an iterative version for performance. Walk me through the trade‑offs and the steps you’d take.

5-8 years experience

  1. 1Design a service that processes hierarchical data (e.g., an org chart) and computes aggregates recursively. How would you ensure it scales and avoids stack overflow in a distributed setting?
  2. 2Explain how you would apply tail‑call optimization or a trampoline technique in a language without native TCO to handle very deep recursion.

8+ years experience

  1. 1Our legacy system uses deep recursive algorithms for query planning, leading to high memory usage. How would you plan a migration to iterative or streaming approaches while keeping correctness across multiple teams?
  2. 2When designing a language runtime, what considerations around the call stack and recursion support influence the choice between a fixed‑size stack and a segmented or growable stack?

Follow-up Questions

  • What happens if the base case is never reached?
  • How does tail recursion affect stack usage compared to regular recursion?
  • Can you estimate the recursion depth that would cause a stack overflow on a typical JVM?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.