Pergunta de entrevista da empresa Cisco

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

Respostas da entrevista

Sigiloso

12 de mar. de 2013

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

Sigiloso

4 de abr. de 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).