Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. For each of the following three program fragments, give an analysis of the running time. First, give the total number of times of each

image text in transcribed

2. For each of the following three program fragments, give an analysis of the running time. First, give the total number of times of each statement being executed. Then give the summed/total time in BigO notation using function with the least order of magnitude. Basically don't say the complexity is O(N9) if it is also O(N2). (21 pts) (a) Sum=0 for (i=1;iN;i++) Sum = Sum +i; (b) Sum =0; for(i=1;iN3;i++)for(j=1;jN2;j++)for(k=1;kN;k++)Sum=Sum+1 (c) Sum =0; for(i =1;iN;i++) for (j=1;ji;j++) Sum = Sum +1 (d) x=100; y=0; for(i =1;iN;i=2i) x=x+i; for (j=1;jN;j++) if(x>y/j) y=y+i/j; else y=y1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Systems For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions