Indicate the total running time of the algorithm

Assignment Help Business Management
Reference no: EM132322726

Consider the following function:

int mystery3(int n)

{

int s = 0;

for (int i=1; i<=n; i++)

{

int ci = 0;

for (int j=1; j<=i; j++)

{

ci+=1;

}

s += ci;

}

return s;

}

i) Indicate the total running time of the algorithm using O-notation (function class). Clearly show your work. You do not need to calculate the exact number of steps but clearly indicate how you arrived at the answer.

ii) Create an English statement to describe what the function does-hint, try running the program in the terminal.

iii) Can this function be improved with respect to its big-O running time? If so, write down the improved function(in pseudo-code or in proper C code). If not, clearly indicate why it cannot be improved (you may use an English explanation -no formal proof necessary)

Reference no: EM132322726

Questions Cloud

Brief description of the program : Input List and Output List, and full pseudocode. Place the pseudocode for each module above the module's Python code.
Establish an appropriate set of guidelines for hacker code : How can you establish an appropriate set of guidelines for hacker code of ethics without becoming a moral relativist?
Explain what is the relevance of the thermal diffusivity : Explain what is the relevance of the Thermal Diffusivity of a brick to the temperature measured on the hot side of a brick wall heated on one side
Connected undirected graph with distinct edge weights : Let G = (V,E) be a connected undirected graph with distinct edge weights. Prove that G has a unique minimum spanning tree.
Indicate the total running time of the algorithm : Indicate the total running time of the algorithm using O-notation (function class). Clearly show your work. You do not need to calculate the exact number
Nfa that recognizes exactly the language described : For each of the following, draw a NFA that recognizes exactly the language described.
What temperature would the plate heat up to : How much radiant heat energy would it be emitting over every square metre of surface area - what temperature would the plate heat up to
What is cli and gui : What is CLI and GUI? And what are the similarities/differences about them?
Directed graph with negative-weight edges : Give a simple example of a directed graph with negative-weight edges for which Dijkstra's algorithm produces incorrect answers.

Reviews

Write a Review

Business Management Questions & Answers

  Selection and recruitment stages

How can an employer exhibit discrimination during the selection and recruitment stages? How can this risk of discrimination be reduced or eliminated?

  Create-a boundaryless structure

1. Create-a boundaryless structure with the manufacturer in South Africa.

  Statement of your personal code of ethics

Provide a statement of your personal code of ethics. Include at least five (5) principles in your statement and give an explanation and justification for each of these principles derived from your reading of the pertinent literature and the textbo..

  Mitigating project risks

Within the Discussion Board area, write 350-600 words that respond to the following questions with your thoughts, ideas, and comments.

  Unemployment and poverty in sub-saharan africa

THE ROLE OF THE ENTREPRENEUR IN MITIGATING UNEMPLOYMENT AND POVERTY IN SUB-SAHARAN AFRICA - Introduce the contemporary perspectives relevant to the study.

  Draw a sipoc diagram about a personal process you have

After watching the videos, draw a SIPOC diagram about a personal process you have. You may draw the diagram by hand or use a tool such as excel or word, or you may video or take a picture of your diagram.

  Strategies for incident response to business

How might you apply the four main strategies for incident response to this business?

  Discuss the characteristics of the spot market

1. In a short essay, discuss the characteristics of the spot market. 2. What is configuration? Briefly list and discuss the factors that influence value chain configuration.

  Economic crisis companies are facing today

Because of the economic crisis companies are facing today, there has been a sharp decline in worker confidence in business.

  Exchange rate between japanese yen and british pound

Suppose that last year, the nominal exchange rate between the Japanese yen and the British pound was ¥225.0 per €1.0, one unit of Japanese output cost

  Explain profit sharing plans and esops

Explain profit sharing plans and ESOPs. What are the advantages and disadvantages of each?What factors will contribute to a successful variable pay plan?

  Quality assurance manager for an all air cargo airline

You have recently been assigned as a quality assurance manager for an all air cargo airline. You have reviewed previous company quality defects and want.

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