Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Measure the time cost (efficiency) of an algorithm to use the computers clock to obtain an actual runtime. Via benchmarking/profiling implement an algorithm that counts
Measure the time cost (efficiency) of an algorithm to use the computers clock to obtain an actual runtime. Via benchmarking/profiling implement an algorithm that counts from 1 to a million, time the algorithm and output the running time to the terminal window. Triple the problem size of this number and repeat this process. After four such increases, output the results of your program. For simplicity, measure the efficiency of the algorithm below.
#Start the algorithm work = 1 for x in range(problemSize): work += 5 work -= 5 #end of algorithm
Console
Problem Size Seconds 1,000,000 0.1028 3,000,000 0.3800 9,000,000 0.9046 27,000,000 2.7337
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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