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
What does a lock object involve? The tables. The lock argument.

One way of demonstrating the importance of good ID is by showing tangible benefits that can be talked about in cash terms. Within a business, good ID can lead to benefits such as h

Many physicists believe that the universe is governed by a single system. A system which is capable of describing the behaviour of the very large (stars and planets) and the very s

Advantage  1.       By doing threading we neglect the recursive method of traversing a Tree , which makes use of stack and consumes many memory and time . 2.       The node

Explain Lexical substitution during macro expansion ? Lexical substitution is used to produce an assembly statement from a model statement. Model statements have 3 kinds of str

I think if 8259 gives interrupt then it will be serviced instantly but since into pin is left hanging the insr bit will never be set...and so whenever any interrupt occurs

Program counter and Stack pointer all have 16 bits.

State the scope of security policy The scope of security policy depends on aspects such as the size of the Intranet site, type of information hosted on it, and the number of u

Describe five bit even parity checker. Ans: Five bit even parity checker: EX-OR gates are utilized for checking the parity as they generate output 1, while the input ha

Speedup First, we take the speedup factor which is we see how much speed up performance we achieve by pipelining. First we take ideal case for measuring the speedup. Let n b