Cisco Interview Question

how efficient is it to implement fibonacci of a nth number using recursion.

Interview Answers

Anonymous

Mar 12, 2013

It wont be the best solution using recursion. Need to use iterative approach using 3 variables. SC: o(n), TC = o(1)

Anonymous

Apr 4, 2010

not efficient. if you apply recursion to a nth fibonacci , the order of efficiency reduce by the order of c^n. if you implement it iteratively, it can be solved in nearly O(n).