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

Define frequency division - application of flip flops, Define Frequency Div...

Define Frequency Division - Application of Flip Flop? When the pulse waveform is applied to the clock input of a J-K flip-flop that is connected to toggle, the Q output is a s

What problem does the namespace feature solve, Multiple providers of librar...

Multiple providers of libraries may use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature

What is floppy drives, Q. What is Floppy Drives? Disks used with a flop...

Q. What is Floppy Drives? Disks used with a floppy disk drive are small removable disks fabricated of plastic coated with magnetic recording material. Disk rotates at 360RPM. F

What is trp, TRP is the number of clock cycles required to terminate access...

TRP is the number of clock cycles required to terminate access to an open row of memory, and open access to the next row. It stand for row precharge time.

Data rate limitations in PSTN's by using nyquist theorem, Explain with the ...

Explain with the help of Nyquist theorem, the data rate limitations in PSTN's. Data rates in PSTNs : A voice channel in a public switched telephone network is band restricted

What is ipc, What is IPC? What are the various schemes available? The t...

What is IPC? What are the various schemes available? The term IPC (Inter-Process Communication) explains various ways by which different process running on some operating syste

Order in which filters get implemented, If we have multiple filters implet...

If we have multiple filters impleted, what is the order in which these filters get implemented?   Ans) 1. Authorization filters 2. Response filters 3. Action filters

What is known as multiphase clocking, What is known as multiphase clocking?...

What is known as multiphase clocking? When edge-triggered flip flops are not used, two or more clock signals may be required to guarantee proper transfer of data. This is calle

Why sram are said to be volatile, Why SRAM are said to be volatile? Bec...

Why SRAM are said to be volatile? Because their contents are lost when power is interrupted. So SRAM are said to be volatile.

What is parallel sections construct, What is Parallel Sections Construct? ...

What is Parallel Sections Construct? The parallel sections construct is a shortcut for specifying a parallel construct comprising one sections construct however no other statem

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