int fib(int n)
{
if (n <= 2) return 1
else return fib(n-1) + fib(n-2)
}
How do I differentiate between O(2^n) and O(n^2)?
If there is a recursive function
int fib(int n)
{
if (n <= 3) return 1
else return fib(n-1) + fib(n-2) + fib(n-3)
}
would the time complexity be O(3^n)?

New Topic/Question
Reply



MultiQuote








|