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




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
The first digit of a decimal constant must be Decimal constants having of a set of digit, 0 to 9, preceded by an optional - or + sign.

Explain a public key encryption system? A public key encryption system permits only the correct receiver to decode the data.

What is write-through protocol? For a write operation using write-through protocol during write-hit: The cache location and the major memory location are updated concurrently.

Give difference between assembler and interpreter. Assembler: It is the translator for an assembly language of computer. An assembly language is a low-level programming langu

Object Repository means not a set of objects. It's a common repository for all the people (Testing, Developers) for seeing all the data in one Login. For example QA needs

Common toes deformities are: 1. Hallux valgus: Deviation of great toe towards the second toe resulting in prominence of first metatarsal head.  Later on there is formation of

Thematic Analysis & Interpretation: The next steps in analysis are to move beyond what is literally there in the image (formal visual elements) and examine the meaning they re

By using Rwatch, Awatch command in GDB we can set read or write watchpoint for a variable.

What are the different storage classes in C?  Storage classes in C  There are four storage classes in C:  a. Automatic storage class:  b. Register storage class:  c

Engineering and Scientific Software Engineering  and  Scientific  software  has  been  characterized  with "number crunching" algorithms. Application starts from astronomy t