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 working of broad band ISDN. BISDN Configuration: Figure shows how access to the BISDN network is accomplished. All peripheral devices are interfaced to the acces

NetDynamics Application Server was the primary Java-based integrated software platform. The product was developed by NetDynamics Inc. As Java became the dominant development langua

What is the difference between Commit-work and Rollback-Work tasks? Commit-Work statement "performs" many functions relevant to synchronized execution of tasks.  Rollback-work

What are the central interfaces of the R/3 system? There are three central interfaces:- Presentation Interface. Database Interface. Operating system Interface.

What are the various address Translation schemes? Explain which scheme is used in Internet? Translation from a computer's protocol address to a corresponding hardware address i

Convert the following into SOP form 1. (A+B) (B'+C) (A'+ C) 2. (A'+C) (A'+B'+C') (A+B') 3. (A+C) (AB'+AC) (A'C'+B)

create a stored procedure to debit a bank account user must enter account no. and amount to debited from account .the minimum balance in account should be 500. if the debited amoun

What are two methods of modifying SAP standard tables? Append Structures and Customizing Includes.

Q. Explain working of Bit Serial Associative Processor? When associative processor accepts bit serial memory organization subsequently it is known as bit serial associative pr

Question: Write a MathCad solution to compute the ellipsoid radii at a point. Use the defining parameters for the GRS80 ellipsoid - a and f - in table 19.1. Program Equation 19