C++ Lec10 IIT
C++ Lec10 IIT
though C++
Abhiram G. Ranade
• Observation:
– Beyond D=45, the time for V(D) seems to increase a
lot.
Understanding the execution V(D)
• The execution of any recursive program can be visualized by
drawing its “Execution tree” or its “Recursion tree”.
• The execution tree is like the trees seen earlier.
• The root corresponds to the original call, say V(10).
• V(10) will make recursive calls to V(9) and V(8).
• So we will have branches going out of the root to “nodes” for
V(9) and V(8).
• From those we will have further branches according to the
further recursive calls that get made.
• No branches leave the nodes corresponding to V(1), V(2).
Demo
• Vtree.cpp
Observations from Vtree.cpp