The big - O runtime for the recursive Fibonacci algorithm is O ( 2 n ) .
Fantastic news! We've Found the answer you've been seeking!
Question:
The bigO runtime for the recursive Fibonacci algorithm is On To see why this is imagine drawing a tree where each node represents a call to the recursive algorithm. A node is a leaf node if it is a base case, otherwise it becomes the parent node for the two recursive calls made by that node. The result is a binary tree. This allows you to visualize how many recursive calls are made when calling the recursive Fibonacci algorithm. The amount of work involved in a single call is constant so now we just need to figure out how many calls are made or how many nodes are in the tree If the binary tree were complete then the number of nodes would be n The tree is not complete since the right side n is always smaller than the left node n This leads to an actual On but for our purposes On is good enough. What is the bigO runtime for the iterative Fibonacci algorithm?
Related Book For
Database management systems
ISBN: 978-0072465631
3rd edition
Authors: Raghu Ramakrishan, Johannes Gehrke, Scott Selikoff
Posted Date: