Indicate the total running time of the algorithm

Assignment Help Basic Computer Science
Reference no: EM132324697

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: EM132324697

Questions Cloud

Address object-oriented classes and objects : Discuss how algorithms address object-oriented classes and objects.
Brief description of the program : Comments including a brief description of the program, Input List and Output List, and full pseudocode. Place the pseudocode for each module above the module.
Array of integers in an ascending order using merge sort : A program which will sort an array of integers in an ascending order using merge sort, and indicate whether each int element is prime.
List the final minimum spanning tree : Mark on the graph showing the intermediate values, and list the final 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.
Provide a summary for the tax issues of earnings of foreign : Ben Watson has asked you, the company's CFO, to research the U. S. GAAP and provide a summary for the tax issues of earnings of foreign subsidiaries.
Calculate the payroll per hour in line with the payroll act : Our payroll is split into calculating the payroll, and disbursing. Since most of our employees are employed as award wage bases, we calculate the payroll.
Idea of the customer relation management : The idea of the Customer Relation Management (CRM) is Good, but this is considered a strategy for business.
Explain importance of project management application systems : Demonstrates sufficient quality of performance to be considered satisfactory or adequate or competent or capable in relation to the learning outcomes

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Convert miles to kilometers and kilometers to miles

Justin Kace is promoting the metric system and wants people to be able to convert miles to kilometers and kilometers to miles.

  Design new admission - registration system

WestEast College hires you as a systems analyst to design its new admission/registration system - The college only accepts online applications.

  Make the economy sustainable

What are the possible ways that the government or the people involved could maybe make the economy sustainable?

  Program that prints on the console the current date and time

Write a program that prints the following numbers on the console 1, 101, 1001, each on a new line.

  It manager of a reputable company

As the IT manager of a reputable company. Write a report showing the stages and steps taken in the implementation of a new network within the company.

  Greenleaf principles of servant leadership

Which of Greenleaf's principles of servant leadership did you implement and learn the most about through completing the servant leadership experience?

  Define transformation in terms of color matching functions

Linear color spaces are obtained by choosing primaries and then constructing color matching functions for those primaries.

  Describe at least three changes that would make it easier

Although the subsequent code compiles and runs, the programmer broke some major readability rules -  Describe at least three changes that would make it easier for other programmers to read and understand the code.

  Describe the two idps detection approaches

Describe the two IDPS detection approaches and discuss the advantages and disadvantages both.

  Summing the total miles run or walked in a typical week

How to make a While-End or (For End) repetition using C code Summing the total miles run or walked in a typical week.

  The load master for a freighter

The load master for a freighter wants to determine the mix of cargo to be carried on the next trip. The ship's volume limit for cargo is 100,000 cubic meters, and it weight capacity is 2,310 tons.

  What are the problems with horizontal and vertical solutions

What expectation should there be for a database management system with regard to handling data control issues such as data security, backup and recovery, and concurrency control? Why?

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