#show graph compaing the time taken to each implementation showgraph(t3,t4,t4/t3) show…
- User
#show graph compaing the time taken to each implementation showgraph(t3,t4,t4/t3)
show the graph comparing the time taken by each implementations
def showgraph(t3,t4,speedupfactor): # Create a figure for plotting fig = plt.figure()
code# Plot the data # pylab cannot plot arrays as numpy array so must first convert plt.plot([1, 2, 3, 4], t3, 'ro-', label = 'Recursive') # y is number of 1000 runs plt.plot([1, 2, 3, 4], t4, 'bo-', label = 'Iterative') plt.plot([1, 2, 3, 4], speedupfactor, 'go-', label = 'speedup') # Add a label to the x-axis plt.xlabel('Number of disks') # Add a label to the y-axis plt.ylabel('time (s)') # Add a title to the plot plt.title('graph of time taken by each implementation using recursive and iterative function') # Display legend plt.legend() # Display plot plt.show()runs the program
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.