AlgoFrames

Order of calls

Standard · Trace the algorithm · about 5 min

fib(4) has just started. Put these calls in the order they start. Each call finishes its left call, fib(n - 1), before it starts its right call, fib(n - 2).

Example 1

Input:

{"n":4}

Output:

3

Constraints

  • The trace uses n = 4.

Learn the idea first: Recursion trees: Fibonacci and repeated work, a visual lesson.

More Recursion trees: Fibonacci and repeated work problems