Code segment , Computer Engineering

Specified  the code segment below and that n is the problem size, answer the following queries:

 

// . . .

int sum = 0;

if(x > 12){

for(int i = 1; i <= n; i = i * 2)
    for( intk = 0; k< n * n; k++)
        sum++;                        // statement1

}

else{

 

for(int i = 1; i <=n; i++)
           sum++;                          // statement2

}

 

 

for(int i = 1; i <= n; i = i +4)
    sum++;                                 // statement3

 

for(int i = 1; i <= n; i++)
    for( intk = 1; k<= n; k = k * 2)
        sum++;                              // statement4

 

  1. Determine the exact number of times statement1, statement2, statement3 and statement4 get implemented.
  2. Explain the Big-Q complexity of this program fragment in the best case. You must display the details of your computations and state the Big-Qrules that are used in the computations.
  3. Explain the Big-Q complexity of this program fragment in the worst case. You must display the details of your computations and state the Big-Q rules that are used in the computations.

 

 

Posted Date: 3/22/2013 3:20:05 AM | Location : United States







Related Discussions:- Code segment , Assignment Help, Ask Question on Code segment , Get Answer, Expert's Help, Code segment Discussions

Write discussion on Code segment
Your posts are moderated
Related Questions
What are the events used for page headers and footers? The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers.

Signify this problem by means of: i.    An Entity Relationship model; ii.    Relational tables. Pete's Programmers is a firm which supplies part time staff on contract to organisat

How exceptions are handled in java? Exception handing In Java: A java exception is an object which describes an exceptional condition which has occurred in a piece of code.

Q. Illustrate Characteristic tables of flip-flops? Excitation Tables Characteristic tables of flip-flops present the subsequent state when inputs and present state are kno

Explain the generic framework for electronic commerce along with suitable diagram? Generic Framework for electronic commerce comprises the Applications of EC (as like banking,

Write a class encapsulating the concept of a circle? I have been working on this program for awhile and this is all I have so far... What are my flaws in the program besides not ha


DUPLICATING PROCESSES : As we mentioned earlier duplicating is a process whereby a master copy is prepared from which a large number of other copies are obtained with the help of

converting 10 ASCII characters to excess three using mplab ide

The scope of the experts system is very limited. It cannot work outside the field it is being used. The users knowledge is required to adjust to new situation. To reduce