Advanced Topics MCQ

Code Tracing: Recursion

Practice mode shows one question at a time and lets students check each answer before moving on.

All AT CS Tests

For practice use only.

Code Tracing: Recursion

Code Tracing: Recursion with immediate answer checks and explanations for Advanced Topics in Computer Science.

Question 1 of 25

Answered 0 of 25

Choose one answer.

Trace the recursive return values. What is printed?

public class RecursionTrace
{
    public static int twist(int n)
    {
        if (n <= 1) return n + 0;
        return twist(n - 1) - twist(n - 2) + n;
    }

    public static void main(String[] args)
    {
        System.out.println(twist(5));
    }
}