Count calls in recursive function evaluation

Quick Overview

This question evaluates understanding of recursion, recursive call trees, and counting function invocations to reason about runtime behavior. It is commonly asked in software engineering fundamentals interviews to assess reasoning about implicit call graphs and algorithmic cost; the domain tested is recursion and algorithmic analysis, and the level of abstraction is conceptual understanding rather than practical implementation.

Count calls in recursive function evaluation

Company: Bitkernel

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Online Assessment

Consider the following recursive function in C-like pseudocode: ```c int x(int n) { if (n <= 3) return 1; else return x(n - 2) + x(n - 4) + 1; } ``` When computing `x(8)`, how many times in total is function `x` called (including the initial call `x(8)` itself)?

Quick Answer: This question evaluates understanding of recursion, recursive call trees, and counting function invocations to reason about runtime behavior. It is commonly asked in software engineering fundamentals interviews to assess reasoning about implicit call graphs and algorithmic cost; the domain tested is recursion and algorithmic analysis, and the level of abstraction is conceptual understanding rather than practical implementation.

|Home/Software Engineering Fundamentals/Bitkernel
Bitkernel logo
Bitkernel
Oct 24, 2025
mediumSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
4
0

Consider the following recursive function in C-like pseudocode:

int x(int n) {
    if (n <= 3) return 1;
    else return x(n - 2) + x(n - 4) + 1;
}

When computing x(8), how many times in total is function x called (including the initial call x(8) itself)?

Loading comments...