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

Properties of vector-based graphic files, Question: a) Write a short no...

Question: a) Write a short note on each of the terminologies below pertaining to multimedia: i) Developers. ii) Users. iii) Authoring Tools. iv) Product. b) Software d

What is interactive reporting, What is interactive reporting? It helps ...

What is interactive reporting? It helps you to make easy-to-read lists.  You can view an overview list first that having general information and give the user with the possibil

How do you find out if a linked-list has an end, By 2 pointers you can find...

By 2 pointers you can find it. One of them goes 2 nodes each time. The second one goes at 1 node each time. If there is a cycle, the one that goes 2 nodes every time will eventuall

2 way staircase switch-truth table logic equation & circuit, A staircase li...

A staircase light is controlled by two switches one at the top of the stairs and another at the bottom of stairs a. Make a truth table for this system. b. Write the lo

Build and evaluate a GAN based model using KERAS, I did not see an option r...

I did not see an option related to machine learning. so i selected computer engineering. Use different datasets such as: paintings by Picasso, Van Gogh, DaVinci

Database, what are the Database designs to avoid?

what are the Database designs to avoid?

Is it possible to create graph form spreadsheets, Is it possible to create ...

Is it possible to create graph form spreadsheets For example IF G5 > 100 THEN "Y" ELSE "N" -  It's also possible to create graphs and charts from spreadsheets (such as using

What do you understand by hit ratio, What do you understand by Hit ratio? ...

What do you understand by Hit ratio? When a processor refers a data item from a cache, if the referenced item is in the cache, then such a reference is called hit. If the refer

Rationales for an effective and independent regulator, Question: (a) W...

Question: (a) What are the rationales for an effective and independent regulator? (b) Across Africa, regulators have established Universal Service Funds (USFs) in order to

Xor gate, The XOR gate. The exclusive OR or XOR gate is similar to a tw...

The XOR gate. The exclusive OR or XOR gate is similar to a two input OR gate. The output of an XOR gate is logic 1 only when one input or the other input is high and is 0 when

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