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
Q. Can you explain about Internet Protocol? Internet protocol specifies the rules which define the details of how computers communicate. It specifies exactly how a packet shoul

Contact-based keyboards employ switches directly. Though they have a comparatively shorter life they are the most preferred type these days because of their lower cost.  Three such

Q. Show the liability of CPU in interrupt cycle? In the interrupt cycle the liability of CPU/Processor is to ensure whether any interrupts have happened checking presence of in

Hi I study master of computer science I have assignment for subject statical natural language processing . I need solved due date on 6 May2014 at 11 pm Australia time I need yo


Define the term package- object oriented modeling A package is a common purpose mechanism for organising elements into groups. Package can also contain other packages. The no

Q Develop a program that accepts decimal number and converts it into given base. Fractional numbers are allowed and negative numbers are not allowed. Also check that entered number

The Concept of Concurrent and Parallel Execution Real world systems are concurrent in nature and computer science is about modeling the real world. Illustrations of real world

Measuring and Improving Cache Performance: 1. Reduce the possibility that 2 different memory block will contend for the similar cache location 2. Additional cache levels

Explain the basic architecture of digital switching systems. An easy N X N time division space switch is demonstrated in figure. The switch can be shown in an equivalence for