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

Why do we call motherboard a motherboard, Motherboard is called as motherbo...

Motherboard is called as motherboard because in the world all borned creature is directly attached to her mother & after it all the relations makes due to her mother so in the simi

What is the length of function code at user-command, What is the length of ...

What is the length of function code at user-command? Every menu function, push button, or function key has an associated function code of length FOUR (for example, FREE), which

What is a good resolution, Q. What is a good resolution? In fact it rel...

Q. What is a good resolution? In fact it relies on your hardware. Hence it's the maximum your hardware can allow you.  But one odd-looking resolution that has become popular is

Describe the uses of credit cards and smart cards, Credit cards and smart c...

Credit cards and smart cards Credit cards comprise a magnetic stripe on the back made up of iron-based particles in a plastic film. Stripe is split up into 3 tracks which a

Define the time when a block of data is ready to be read, The total time to...

The total time to prepare a disk drive mechanism for a block of data to be read from is its ? Ans. latency plus seek time is the total time to prepare a disk drive mechanism fo

What are advantages and drawbacks of flip-flop, What are advantages and dra...

What are advantages and drawbacks of flip-flop? Usually area of a Flip-flop for features in more than a latch. Power consumption is normally higher, because of the area and

Explain conditions under which a deadlock situation arise, What are conditi...

What are conditions under which a deadlock situation may arise? A deadlock situation can arise if the following four conditions hold concurrently in a system:  a. Mutual exc

Replacement policy - cache memories , Replacement policy: On a particul...

Replacement policy: On a particular cache miss we require to evict a line to build room for the new line "In an A-way set associative cache, we have A option of which block

Define bootstrap loader, Define bootstrap loader? The ROM portion of ma...

Define bootstrap loader? The ROM portion of main memory is required for storing an initial program known as bootstrap loader. It is a program whose function is to start the com

Identify the process of entering data into a ROM, The process of entering d...

The process of entering data into a ROM is called ? Ans. The process of entering data in ROM is termed as programming the ROM.

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