https://leetcode.com/problems/fibonacci-number/
The Fibonacci sequence is a set of numbers that starts with 0 and 1, each subsequent number is the sum of the two preceding numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …).
Fib(n) = Fib(n-1) + Fib(n-2)
Base Case
Fib(0) = 0Fib(1) = 1Fibonacci Decision Tree
Top down approaches see it as a conceptual Binary Tree.
F(n-1) has more recursive calls than F(n-2).F(n-1), F(n) has n levels.F(n) means the number of F(1) in its tree, because F(1) is the base cause allowing us adding the result. F(5)
/ \\
F(4) F(3)
/ \\ / \\
F(3) F(2) F(2) F(1)
/ \\ / \\ / \\
F(2) F(1) F(1) F(0) F(1) F(0)
/ \\
F(1) F(0)
O(2^n)O(n)