Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have written a single piece of code that consists of a single for loop with a simple calculation within the loop. I run the
I have written a single piece of code that consists of a single "for" loop with a simple calculation within the loop. I run the code two different times on the same computer, timing the execution for each run. The only change that is made between the two different runs is changing the number of loops that are executed. a. (10 points) If run number 1 is expected to loop 1 million times, and run number 2 is expected to loop 1 billion times, which run should take longer (assume CPls are identical)? (Please justify your answer using the performance equation). b. (10 points) If both runs were found to take the identical amount of time, how many instructions were executed for each program? (assume that the time measurements are perfectly accurate and the CPls are identical) c. (5 points) how long did the program run in each case? d. (5 points extra credit) Please explain what might have caused this? (you must correctly answer 3.a-3.c to receive this extra credit) I have written a single piece of code that consists of a single "for" loop with a simple calculation within the loop. I run the code two different times on the same computer, timing the execution for each run. The only change that is made between the two different runs is changing the number of loops that are executed. a. (10 points) If run number 1 is expected to loop 1 million times, and run number 2 is expected to loop 1 billion times, which run should take longer (assume CPls are identical)? (Please justify your answer using the performance equation). b. (10 points) If both runs were found to take the identical amount of time, how many instructions were executed for each program? (assume that the time measurements are perfectly accurate and the CPls are identical) c. (5 points) how long did the program run in each case? d. (5 points extra credit) Please explain what might have caused this? (you must correctly answer 3.a-3.c to receive this extra credit)
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