HW #1 - a. n^2 + 6n + 4 i. (n^2)+(6*n) +4 b. 5n^3 + 2n + 8...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
David Carothers CS 230 E01 9/12/07 1. Mark the following statements as true or false. a. The lifecycle of software refers to the phrases from the point the software was conceived until it is retired. T b. The three fundamental stages of software are development, use, and discard. F c. The expression 4n + 2n^2 + 5 is O(n). F d. The data members of a class must be of the same type. F e. The function members of a class must be public. F f. A class can have more than one constructor. T g. A class can have more than one destructor. F h. Both constructors and destructors can have parameters. F 2. Consider the following function prototype, which returns the square root of a real number: double sqrt( double x ); What should be the preconditions and post conditions for this function? The input variable and output variable should both be of the double type. Input can not be negative (can't take square root of a negative number) 3. Each of the following expressions represents the number of operations for certain algorithms. What is the order of each of these expressions?
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: a. n^2 + 6n + 4 i. (n^2)+(6*n) +4 b. 5n^3 + 2n + 8 i. n^3 ii. (n^3)*5 iii. 2*n iv. +8 c. (n^2 + 1)(3n + 5) i. n^2 ii. 3*n iii. (n^2) +1 iv. (3*n) +5 v. [ (n^2) +1 ] * [(3*n) +5 ] d. 5(6n + 4) i. 6*n ii. (6*n) + 4 iii. 5 * [ (6*n) + 4 ] 4. Consider the following function: Void funcExcercise4(int x, int y) { Int z; z = x + y; x = y; y = x; cout<< x = <<x<<, y = <<y<<, z = <<z<<endl; } Find the exact number of operations executed by the function funcExcercise4 a. 12 5. Consider the following function: int funcExcercise5(int list, int size) { Int sum = 0; For(int index = 0; index < size; index++) Sum = sum + list[index]; Return sum; } a. Find the number of operations executed by the function funcExcercise5 if the value of size is 10. a. 43 b. Find the number of operations executed by the function funcExcercise5 if the value of size is n. a. 4n+3 c. What is the order of the function funcExcercise5 ? a. O(n)...
View Full Document

Page1 / 2

HW #1 - a. n^2 + 6n + 4 i. (n^2)+(6*n) +4 b. 5n^3 + 2n + 8...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online