Question: Copy and paste your graph below: Based on the data collected, find an expression T(n) to estimate the time (in seconds) it takes to calculate

 Copy and paste your graph below: Based on the data collected,

find an expression T(n) to estimate the time (in seconds) it takes

Copy and paste your graph below:

Based on the data collected, find an expression T(n) to estimate the time (in seconds) it takes to calculate hanoi(n):

T(n)=

2. Use the expression you got in part (b) to estimate the number of years it takes to calculate T(n) and hanoi(n):

T(75)=

T(100)=

CODE FOR GRAPH

from datetime import datetime

def hanoi (n, origin, destination, intermedia):

if n

return 1

else:

a = hanoi (n - 1, origin, intermedia, destination)

b = hanoi (n - 1, intermedia, destination, origin)

return a + b + 1

def timeIt (n, origin, destination, intermedia):

start = datetime.now ()

result = hanoi (n, origin, destination, intermedia)

end = datetime.now ()

elapsed = (end - start).total_seconds ()

return (result, elapsed)

def test ():

done = False

i = 1

while not done:

result, elapsed = timeIt (i, 'left', 'right', 'middle')

print ('time = %11.6fs, hanoi (%2d) = %12d' % (elapsed, i,

result))

if elapsed > 3600.0:

done = True

i = i + 1

test ()

5. Download the file "csc220al.py" from Canvas and run the program. This program will run with either Python 2.x or 3.x It contains a nave implementation to calculate the numbers of the steps to solve the "Tower of Hanoi" problem and gives timing information. When you run the program, it should produce lines similar to the followings 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi( 0.000000s, hanoi ( 0.000000s, hanoi 0.000000s, hanoi( 0.001255s, hanoi( 0.001254s, hanoi time = time - time- time time- time time - 15 31 63 127 time - 255 time - 511 time - (10) 1023 Be patient, the program will take anywhere between 2 to 4 hours to complete. When the program is running, you should minimize any other activities on the computer so the running time data will not be disturbed. Once the program execution is finished, you can use the data to plot the times versus the values of n in a graph. If you use logarithm scale for the times, you will get a curve very close to a straight line (especially towards the timing data at the end). Now visually inspect your curve and discard some beginning data that is not so straight Your curve should now look like the following 5. Download the file "csc220al.py" from Canvas and run the program. This program will run with either Python 2.x or 3.x It contains a nave implementation to calculate the numbers of the steps to solve the "Tower of Hanoi" problem and gives timing information. When you run the program, it should produce lines similar to the followings 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi ( 0.000000s, hanoi( 0.000000s, hanoi ( 0.000000s, hanoi 0.000000s, hanoi( 0.001255s, hanoi( 0.001254s, hanoi time = time - time- time time- time time - 15 31 63 127 time - 255 time - 511 time - (10) 1023 Be patient, the program will take anywhere between 2 to 4 hours to complete. When the program is running, you should minimize any other activities on the computer so the running time data will not be disturbed. Once the program execution is finished, you can use the data to plot the times versus the values of n in a graph. If you use logarithm scale for the times, you will get a curve very close to a straight line (especially towards the timing data at the end). Now visually inspect your curve and discard some beginning data that is not so straight Your curve should now look like the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!