Describe what the function does-hint

Assignment Help Basic Computer Science
Reference no: EM132320222

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

Questions Cloud

Discuss at least three different cpu scheduling algorithms : Discuss at least three different CPU scheduling algorithms with an example pointing out the scenarios when each of those algorithms
Is the duty to prevent insolvent trading a fiduciary duty : BULAW5915 Corporate Law Assignment, Federation University Australia. Is the duty to prevent insolvent trading a fiduciary duty? Why or why not
Estimate the difference with a confidence interval : Math and 146: Introduction to Statistics-Edmonds Community College USA- Estimate the difference with a 95% confidence interval.
Unique minimum spanning tree : Let G = (V,E) be a connected undirected graph with distinct edge weights. Prove that G has a unique minimum spanning tree.
Describe what the function does-hint : Create an English statement to describe what the function does-hint, try running the program in the terminal.
Draw a nfa that recognizes exactly the language : For each of the following, draw a NFA that recognizes exactly the language described.
Dijkstra algorithm produces incorrect answers : Give a simple example of a directed graph with negative-weight edges for which Dijkstra's algorithm produces incorrect answers.
Explain your understanding of eigen vectors and eigen values : What are some limitations or disadvantages of multivariate methods generally? Explain your understanding of eigen vectors and eigen values?
Limitation and vulnerabilities of the mobile payment system : What is the limitation and vulnerabilities of the mobile payment system? Are there any examples for details?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Presentation-the content or the design

1. Which is more important about a presentation-the content or the design? Why?

  Program that animates a car so that it moves across fame

Change the RectangleComponent for the animation program in Section 9.10 so that the rectangle bounces off the edges of the component rather than simply moving outside.

  Develop a wbs for the process for recovering your computer

Develop a WBS for the process for recovering your computer. Estimate the time it will take you to perform each task.

  A useful array populating the array processing the items

Select a task a program could perform over an array of items that would be useful. Your task must include the following: A useful array Populating the array Processing the items in the array Outputting the results of the processing (This may or may n..

  What is machine learning

1) What is machine learning? 2) What is the relationship between Machine Learning & Big Data? 3) Provide a few business cases where Machine Learning would help.

  Features of the graph

In Problem use the derivative to locate critical points and determine a viewing window that shows all features of the graph.

  Describe different techniques to produce and manage backups

Why it is a challenge to achieve Separation of Duty if all steps take place on a single computer system?

  Would you like to see different software installed in labs

Would you like to see different software or hardware installed in the computer labs?

  What''s the relationship between voltage

What's the relationship between voltage, current, and resistance? How can voltage, current and resistance be used in circuit design?

  Find the measure of displacement

Suppose a biologist is trying to net a fish under water. Find the measure of displacement if t measures 10 centimeters, the measure of angle A is 41°, and the measure of angle B is 60°.

  Write pseudo code for an iterator

Your pseudo code must define the standard iterator functions open(), next(), and close(). Show what state information the iterator must maintain between calls.

  Think about your own consumption of video

Think about your own consumption of video. What kinds of entertainment and informational videos are you most likely to view? 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