Code segment , Computer Engineering

Assignment Help:

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.

 

 


Related Discussions:- Code segment

What is graceful degradation, What is graceful degradation? In multipro...

What is graceful degradation? In multiprocessor systems, failure of one processor will not halt the system, but only slow it down by sharing the work of failure system by other

Difference between search and search all, SEARCH is a sequential search fro...

SEARCH is a sequential search from the starting of the table. SEARCH ALL is a binary search, continually dividing the table in two halves until a match is found. SEARCH ALL is more

Illustration of a memory organization, Q. Illustration of a memory organiza...

Q. Illustration of a memory organization? Let's consider an illustration of a memory organization as displayed in Figure below in that main memory can store 32K words of 12 b

Show the shared programming using library routines, Q. Show the Shared Prog...

Q. Show the Shared Programming Using Library Routines? The mainly well-liked of them is use of combo function known as fork() and join(). Fork() function is used to initialize

Show the connections used in sound cards, Q. Show the Connections used in S...

Q. Show the Connections used in Sound cards? Sound cards must have connections to allow different functions.  One of the most significant is MIDI port (MIDI signifies Musical I

Technology management, These five questions are part of the assignment. The...

These five questions are part of the assignment. The answers of each question can be written in around 300 words (with relevant diagrams and Refrences). Assignement should be comnp

What are the main features of uml, What are the main features of UML ...

What are the main features of UML Defined system structure for the object modelling Support for all different model organization Strong modelling for behaviour an

Interfacing of keyboards, Q. Interfacing of keyboards? The keyboard emp...

Q. Interfacing of keyboards? The keyboard employs a special Input/output port which is similar to a serial port however doesn't explicitly follow the RS-232 serial port standar

Define superscalar processors, In scalar processors just one instruction is...

In scalar processors just one instruction is implemented per cycle which means just one instruction is issued for each cycle and only that one instruction is completed however the

Fixed arithmetic pipelines, Fixed Arithmetic pipelines  We obtain the e...

Fixed Arithmetic pipelines  We obtain the example of multiplication of fixed numbers. The Two fixed-point numbers are added by the ALU using shift and add operations. This sequ

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd