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
Example of Variables and quantifiers: We should have started with something such which reflects the fact that we're really talking for some meal at the Red Lion, neverthe

Which is the best programming language to learn?

What is a resource-allocation graph? Deadlocks can be described more precisely in terms of a directed graph known as a system resource allocation graph. This graph having of a

Can both client and server use the same protocol port on the same computer at the same time? Explain. Client and server can't use similar port number on similar computer at ide

Building on their knowledge of research methods and their interest in a particular aspect of information technology this assessment enables students to put this knowledge into prac

java program for implementation of telnet services

What is phase encoding or Manchestor encoding?  It is the method for combining clock information with data. It is a scheme in which alters in magnetization occur for each data

Q. Prove using Boolean Algebra 1. AB + AC + BC' = AC + BC' 2. (A+B+C) (A+B'+C') (A+B+C') (A+B'+C)=A 3. (A+B) (A'+B'+C) + AB = A+B 4. A'C + A'B + AB'C + BC = C + A'B

Closed System: It's isolated from environment influences. It operates on factors within System itself. It is also described as a System which involves a feedback loop, a control e

Which types of software programs are usually supported? Our organization is unique in that we are very flexible and can meet most client requires relative to the integration of