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
Explain the term Electronic Data Interchange (EDI). Electronic Data Interchange (EDI) may be generally easy to understand as the replacement of paper-based purchase orders alon

Define underflow and overflow. Underflow: If the result the arithmetic operation including n-bit numbers is too small to show by n-bits, underflow is said to occur. Overflow

What is an imperative statement? Ans. Shows an action to be performed throughout execution of assembled program is an imperative statement.

Application Using Shift Operations Rotate and Shift instructions are helpful even for division andmultiplication. These operations are not normally available in high-level lang

explain classification of computers in detail.also explain various application areas of computers

What are the different between hypertext hypermedia? Hypertext is fundamentally the same like regular text; this can be stored, read or searched and edited along with a signifi

What are the functions of virtual file system (VFS)? a. It splits file-system-generic operations from their implementation explaining a clean VFS interface. It allows transpare

Explain the advantages of computer Computer is one of the main components of an Information Technology network and getting increasing popularity. Nowadays, computer technology

Logic Programs: A subset of first order logic is "Logic programs". However logic program having a set of Horn clauses that are implication conjectures when there is a conjunct

Public Key Infrastructure solutions The use of public-key based security systems requires great attention and due care in design and management of security features. The secur