Question
Copy your original hanoi towers solution code to a new file (maybe 'complexity.py'). (use any hanoi towers program) Modify your code to take the following
Copy your original hanoi towers solution code to a new file (maybe 'complexity.py'). (use any hanoi towers program)
Modify your code to take the following command line arguments:
springsemester% python complexity.py USAGE: complexity.py
Using the clock() method of the Python time module, measure the processor time required for function calls with min # rings <= rings <= max # rings; increment the number of rings by 1 each time you call the function.
At the end, your code will print a table reporting seconds of CPU time versus number of rings. You should have an upper limit on the number of rings that requires significant CPU time (say ~ 30 seconds).
It is suggested that you disable the print statements in the HanoiTowers function - they add an element of uncertainty that is irrelevant to measuring complexity.
Make a log plot of the data (log execution time VS number of rings) to answer these questions :
* Do you see evidence that the time complexity is exponential? Why so, or why not?
* If 'yes' to the above, what is your estimate of the base of the exponential function?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started