Question

Exercises • Determine running time for the following code fragments: (a) a = b + c; d = a + e; (b) sum = 0; for (i=0; i<3; i+

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

take constant execute 2 . for will to adding ab+c date: a numbers time. Therefore, . time taken statements are constant. TODO

d) for (P=0; iº4n4; i++) for (iaitu jangjitt) ^ :. temp- Ali][j]; [1] [j].: AC3] [1]; Alj] li] = temp; liec, i loop gets isl,e) sum=o for liali Pean, itt) for (j<!; 342n;*32) Sum + outer for loop gets executed n times every iteration of outer loop,

Add a comment
Know the answer?
Add Answer to:
Exercises • Determine running time for the following code fragments: (a) a = b + c;...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For each of the following six program fragments: a. Give an analysis of the running time...

    For each of the following six program fragments: a. Give an analysis of the running time (Big-Oh will do). b. Implement the code in the language of your choice, and give the running time for several values of N. Pseudo Code Implementation Analysis of runtime time (Big-Oh) (1) sum = 0; for(i = 0; i < n; ++i) ++sum; (2) sum = 0; for(i = 0; i < n; ++i) for(j = 0; j<n; ++i) ++sum; (3) sum = 0;...

  • Using C++ please explain What is the Big-O time complexity of the following code: for (int...

    Using C++ please explain What is the Big-O time complexity of the following code: for (int i=0; i<N; i+=2) { ... constant time operations... Select one: o a. O(n^2) O b. O(log n) c. O(n) O d. 0(1) What is the Big-O time complexity of the following code: for(int i=1; i<N; i*=2) { ... constant time operations... Select one: O O a. O(n^2) b. 0(1) c. O(n) d. O(log n) O What is the Big-O time complexity of the following...

  • Expert G8A 1.4.6 Give the order of growth (as a function of N) of the running...

    Expert G8A 1.4.6 Give the order of growth (as a function of N) of the running times of each of the following code fragments: a. int sum -0 for (int n-N; 0: n / 2) for(int i 0; i < n; i++) sum+ b int sum-0 for (int i-li<N; i'-2) for Cint 3-0:3 i: j) sum++ 4Analysls of Algorithms int sum 0 for (int i-1i<N: i-2) for Cint i-0:3N: j) sum++

  • 1.4.6 Give the order of growth (as a function of n) of the running times of...

    1.4.6 Give the order of growth (as a function of n) of the running times of each of the following code fragments: a, int sum=0; for (int k n: k > 0; k /= 2) for (int i 0; ǐ < k; İ++) sum++; b.int sum 0; for (int i = 1; i < n; i *= 2) for (int j = 0; j < i; j++) sum++; int sum = 0; for (int í = 1; i < n;...

  • Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms...

    Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. Show your work b) void func(int n) { for (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++i) { System.out.println("i = " + i); System.out.println("j = " + j);

  • Question 1 (25 pts) Find the running time complexity for the following code fragments. Express yo...

    Question 1 (25 pts) Find the running time complexity for the following code fragments. Express your answers using either the Big-O or Big-Θ notations, and the tightest bound possible. Justify your answers. for(int count O , i -0; i < n* n; i++) for(int i0 ; j <i; j++) count++ for(int count O , i -0; i

  • Describe the order of magnitude of the following code section using Big(O) notation. k=0; for (i=...

    Describe the order of magnitude of the following code section using Big(O) notation. k=0; for (i= 0; i<N; i++)

  • Data Structures and Algorithms For each of the following program fragments, give an analysis of the...

    Data Structures and Algorithms For each of the following program fragments, give an analysis of the running time using Big-Oh notation. Do not give formulas, but analyze every line to calculate the running time, e.g. sum = 0 is equal to 1 unit time ... b. sum = 0;    for( i = 0; i < n; i++)            for( j = 0; j < i*i; j++)                  for( k = 0; k < j; k++)                                           sum++; c. sum =...

  • Give a big-Oh characterization, in terms of n,of the running time for each of the following...

    Give a big-Oh characterization, in terms of n,of the running time for each of the following code segments (use the drop-down): - public void func1(int n) { A. @(1). for (int i = n; i > 0; i--) { System.out.println(i); B. follogn). for (int j = 0; j <i; j++) System.out.println(j); c.e(n). System.out.println("Goodbye!"); D.@(nlogn). E.e(n). F.ein). public void func2 (int n) { for (int m=1; m <= n; m++) { system.out.println (m); i = n; while (i >0){ system.out.println(i); i...

  • Can you explane this quastion step by step 29) What is the output of the following...

    Can you explane this quastion step by step 29) What is the output of the following program? main () { int i,j,sum= 0, time 01 ; for (i-1;i<6; i++) { j-0; time*=i; while (j<i)(sum+=j;j++;) sumt=time;} printf ("%d 8d", sum, time); Je a) 20 173 b) 120 173 c) 173 20 d) 20 120 e) 173 120

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT