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
Q. What do you mean by SSI chips? The 3 rd generation computers mostly used SSI chips. One of the key concepts that were brought forward for the duration of this time was conc

What are the use of job queues, ready queues and device queues? As a process enters a system they are put in to a job queue. These queues having of all jobs in the system. The

The Need Of Parallel Computation With the advancement of computer science (CS), computational speed of the processors has also improved many a time. Moreover, there is certain

Q. Demonstration of sorting problem? The term sorting implies organising elements of a provided set of elements in a specific order i.e. descending order / ascending order / al

Define Top-down parsing Techniques Top-down parsing can be observed as an attempt to find left-most derivations of an input-stream through searching for parse trees using a top

Name some popular storage devices In contrasts with storage, which 1) retains data and programs irrespective of whether they are currently in use or not, (2) retains data

Node at the highest level in the structure is known as?? Root.

Object Orientation and Analysis An Object is anything that exists within the problem domain that can be recognized by data and/or behaviour. An example of an object is a bike.

a) Input names of students from the user, terminated by "ZZZ", 0, 0, 0 and create a data file grades with records of the following form: Student (string), test1 (integer), test2 (i

Question: (a) List five main characteristics of ‘Prototyping'. (b) Describe briefly why ‘Prototyping' is essential to Rapid Application Development. (c) Describe the 2 t