Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Q7. (13 points) a) (12 points) Run each piece of code below and record the actual time (e.g. seconds) it takes. Use a desktop or

Q7. (13 points) a) (12 points) Run each piece of code below and record the actual time (e.g. seconds) it takes. Use a desktop or laptop. DO NOT use an online complier. Pay attention (and draw your own conclusions) to the following issues. You do NOT need to write down your conclusions. 1. runtime_print has the same code as runtime_increment except that instruction res = res+1 was replaced with print instruction. Notice how this affects the time the code takes to run. 2. After you record the time for runtime_increment, pay attention to how the performance gets worse as N gets larger. 3. After you record the time for runtime_pow, note how much faster the performance deteriorates (i.e. it takes too long to run even for small values of N such as 20). Compare that with the other 2 functions (compare both the actual time, and the time complexity). In the table below the code fill in the time complexity (as ) and the approximate clock time each function takes to run. You do NOT need to show your derivations for computing . You also do not need to report the exact time. You can say: < 1 sec, few seconds, few minutes, more than 15 minutes void runtime_increment(int N){ int i, k, t, res = 0; for(i = 1; i <= N; i=i+1) for(k = 1; k <= i; k++) for(t = 1; t <= N; t++) res = res + 1; } void runtime_print(int N){ int i, k, t; for(i = 1; i <= N; i=i+1) for(k = 1; k <= i; k++) for(t = 1; t <= N; t++) printf("A"); } Function Values of N 10 100 300 1000 runtime_increment (_____________) runtime_print (_____________)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions