Assume a typical runtime stack is used for the recursive function mystery(n) as defined earlier.
How many total function calls (stack activations), including the initial call, are made to compute mystery(4)?
Solution :
The correct option is 15.
To understand why computing mystery(4) requires exactly 15 total function calls, we can analyze the standard recursive structure of the function. Typically, a function like mystery(n) that exhibits this behavior is defined as follows:
- Base Case: If , it returns immediately (performing 1 activation and making no further recursive calls).
- Recursive Step: If , it makes two recursive calls to mystery(n - 1).
We can visualize and count the total function calls (stack activations) by constructing a recursion tree for mystery(4):
1. Level 0 (Initial Call):
- mystery(4) is called (1 call).
- Since 4 > 1, it triggers 2 recursive calls: mystery(3).
2. Level 1:
- There are 2 calls of mystery(3).
- Each mystery(3) call triggers 2 recursive calls: mystery(2) (making a total of 4 calls).
3. Level 2:
- There are 4 calls of mystery(2).
- Each mystery(2) call triggers 2 recursive calls: mystery(1) (making a total of 8 calls).
4. Level 3 (Base Case):
- There are 8 calls of mystery(1).
- Since 1 ≤ 1, these calls hit the base case and return immediately without making any further calls.
To find the total number of function calls, we sum the number of activations at each level of the recursion tree:
Thus, a total of 15 stack activations are made to compute mystery(4).
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
SSC CHSL Tier-1 Shift 1 2 July 2024 question paper with answers and detailed solutions. This practice paper covers questions from General Intelligence & Reasoning, General Awareness, Quantitative Aptitude, and English Language as asked in the SSC CHSL Tier-1 examination. Practice the SSC CHSL 2 July 2024 Shift 1 paper to understand the exam pattern, question types, difficulty level, and important topics for upcoming SSC CHSL exams.
SSC CHSL Tier-1 Shift 2 held on 2 July 2024 question paper with answers and detailed solutions. This previous year paper covers General Intelligence & Reasoning, Quantitative Aptitude, General Awareness, and English Language. The SSC CHSL Tier-1 exam was conducted in CBT mode with 100 questions for 200 marks and a 60-minute duration.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.