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
Blue Sky events is an organisation that devices and runs large outdoor events. They have been commissioned to organise and run an event for four months over the summer period in a

There are many different forms of micro-controller and a manufacturer, selecting the proper micro-controller for your application is one of the critical decisions which controls th

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

With the increasing use of more and higher level languages manufacturers had offered more powerful instructions to support them. It was claimed that a stronger instruction set will

pebble merchant

What is the system call available to transmit a signal? System call Kill is used to send a signal to a method or a group of processes. Int kill (pad tepid, Int sig); This

Q. What do you mean by Mouse Protocols? Mouse protocol is the digital code to that signal from the mouse gets converted. There are four main protocols: Microsoft, Mouse Systems

Q. Code Density and Smaller Faster Programs? Memory was very expensive in older computer. So there was a need of less memory utilization, which is it was cost effective to have

Question: (a) Provide types of computer systems and briefly describe each one. (b) With the help of example, explain the difference between open source software, freeware a

Q. Describe about Micro-controllers? Micro-controllers: These are a specialized device controlling computer which comprises every function of computers on a single chip. Chip