Quant Memo
Coding/●●●●

Tribonacci, three-way recursion but still linear

The Tribonacci sequence sums the previous three terms:

T(n) = T(n-1) + T(n-2) + T(n-3),  T(0) = 0,  T(1) = 1,  T(2) = 1

so it runs 0,1,1,2,4,7,13,24,44,0, 1, 1, 2, 4, 7, 13, 24, 44, \dots

Why is the naive recursion even worse than Fibonacci here, and how do you get it to O(n)O(n)?

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions