Skills101
← All practice quizzes

Quiz: Recursion and Stack Frames

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

See what really happens in memory when a function calls itself. Trace stack frames, read recursion trees, count calls, compare recursion with loops, and solve Tower of Hanoi and permutations.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does this print?

    #include <stdio.h>
    void f(int n) {
        if (n == 0) return;
        f(n - 1);
        printf("%d ", n);
    }
    int main(void) {
        f(4);
        return 0;
    }
    
  2. Question 2

    What does a stack frame NOT normally contain?

  3. Question 3

    How many moves does Tower of Hanoi need for 5 discs?

  4. Question 4

    What does this print?

    #include <stdio.h>
    int g(int n) {
        if (n <= 0) return 0;
        return n + g(n - 2);
    }
    int main(void) {
        printf("%d", g(7));
        return 0;
    }
    
  5. Question 5

    Why is the naive recursive Fibonacci slow?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →