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

Which is the slowest sorting procedure, The slowest sorting procedure is   ...

The slowest sorting procedure is    Bubble Sort is the slowest sorting process.

Process of an e-mail transfer across the internet, Q. Process of An e-mail ...

Q. Process of An e-mail transfer across the Internet? When you open your mail client to read your e-mail, this is what normally happens: 1. Mail client (Netscape Mail, Micro

Demorgan''s first theorem, DeMorgan's first theorem shows the equivalence o...

DeMorgan's first theorem shows the equivalence of which logic gate ? Ans. DeMorgan's first theorem depicts the equivalence of NOR gate and Bubbled AND gate. For De Morgan's

What is thread, What is Thread? A thread, sometimes termed a lightweigh...

What is Thread? A thread, sometimes termed a lightweight process (LWP), is a fundamental unit of CPU utilization; this comprises a thread ID, a register set, a program counter

Find two negative polarity items - artificial intelligence, This question c...

This question can be answered either with respect to English or with respect to a language other than English. (If you you are not a native speaker of the language of your choice,

Which datatype cannot be used to define parameters, Which datatype cannot b...

Which datatype cannot be used to define parameters. Type F datatype is not used to explain parameters.

Write the truth table of NOR gate, Write the truth table of NOR gate. Ans...

Write the truth table of NOR gate. Ans. The truth table for NOR gtae is shown below:

Hyper-threading, Hyper-threading, officially known as Hyper-threading Techn...

Hyper-threading, officially known as Hyper-threading Technology (HTT), is Intel's trademark for their execution of the simultaneous multithreading technology on the Pentium 4 micro

Discuss about fourth generation electronic computers, Fourth Generation (19...

Fourth Generation (1972-1984) The next generation of computer systems used the large scale integration (LSI -1000 devices per chip) and very large scale integration (VLSI - 100

How can a shift register be used as a counter, What is a shift register? Ca...

What is a shift register? Can a shift register be used as a counter? If yes, explain how?     Ans: Shift Register: A register wherein data gets shifted towards left or right

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