CMPT 127 Lecture Notes - Lecture 4: Maxima And Minima, Pseudocode, Common Interface

160 views4 pages

Document Summary

Cmpt 125 assignment 1 (due friday, feb 3 3:00pm in the csil dropbox) Consider the following function int mystery3(int n){ int s = 0; for (int i=1; i<=n; i++) { ci+=1; s += ci; return s; int ci = 0; for (int j=1; j<=i; j++){ [3] indicate the total running time of the algorithm using o-notation (function class). You do not need to calculate the exact number of steps but clearly indicate how you arrived at the answer. [2] write an english statement to describe what the function does hint, try running the program in the terminal. 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) In the following segment of code, void say_hello(int n){ for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { puts(hello);

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents