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
Arithmetic-logic section in computer system: The   arithmetic-logic section performs arithmetic   operations, such subtraction, addition, multiplication, and division. Throug

Q. Options with DIR in DOS? You can use a number of options with DIR. To get the list of files from any other drive, denote the drive name followed by ':' with DIR. For exam

As per the JMS specification, when you are in a transaction, the acknowledge Mode is ignored. If acknowledge() is known as within a transaction, it is ignored.

Define the Unified Modelling Language  (UML) is used to express construct and relationships of complex systems. This was created in response to a request for proposal (RFP) fro

Artificial intelligence ("AI") can mean a lot of things too many people. Much confusion arises that the word 'intelligence' is ill-defined. The phrase is so broad that people have

Dictator Dim wants to replace counting, in particular, counting the population of his land. To keep an accurate population count, Dictator Dim has instructed his secretary to add o

Q. Illustrate Domain Name System? Domain name is a name which is given to a network for ease of reference. Domain refers to a group of computers which are known by a single com

What is dialog Module? A dialog Module is a callable sequence of screens that does not belong to a certain  transaction. Dialog modules have their module pools, and can be know

How does CPU know that an interrupt has taken place? There needs to be a line or a register or status word in CPU which can be increased on occurrence of interrupt situation.

What is a Table attribute? The table's attributes verifies who is responsible for maintaining a table and which types of access are permitted for the table.  The most signific