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
Hazard in pipeline - computer architecture: A hazard in pipeline .-removing a hazard frequently need that some instructions in the pipeline to be permitted to proceed as othe

It is recommended that you capture your assignment as a Hierarchical Design in Multisim. Look at the Help topic Working with Larger Designs. Design and thoroughly test each module

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

Constant Voltage Sources An ideal constant voltage source maintains a given voltage across its load regardless of the current drawn from it .Most 'every-day' power supplies a

write an assembly language program for fibonacci series?

Define the role of organizationin computer architecture The organization is the set of resources that realizes the architecture which include the CPU, the memory and I/O contro

Syntax of recursion int fib(int num) /* Fibonacci value of a number */ {      switch(num) { case 0: return(0); break; case 1: return(1); break; default:  /* Incl

Define the Process of dynamic modelling: Analyse applicability of actions Recognize object states Create dynamic model diagram Express every state in terms o

Allocation of Bits among Opcode and Operand The trade-off here is between numbers of bits of opcode vs. the addressing capabilities. An interesting development in this regard i

Laptop computers Laptop computers have the obvious advantage over desk-top computers (PCs) in that they are fully portable. This is of specific value if a user wishes to do wor