COMS 1403 Exam 3 Study Guide – Ch5, 6, 7

COMS 1403
Exam 3 Study Guide – Ch5, 6, 7

Specific things you should make sure you know:
1. Give the definition of an algorithm
2. Identify which type of pseudocode primitive each of the following is an example of:
a. name ? expression ________________________________________
b. if condition then action ________________________________________
c. while condition do activity ________________________________________

3. What is the difference between iteration and recursion?
4. Solve the following problems using order of operations rules:
a. 4 – 2 ^ 4 + 2 * 4 / 2
b. (4 – 2) ^ 4 + 2 * 4 / 2
c. 4+2^(3+2) – 4/2
d. 4+2^(3+2 – 4)/2
5. Assume you have a sorted list of 3000 names.
a. On average, how many names would be interrogated in a sequential search? _________
b. Worst case scenario: How many names would be interrogated in a sequential search? ________
c. Worst case scenario: How many names would be interrogated in a binary search? ________
6. Explain why declaring a tax rate as a constant at the top of your program by using the code similar to ?const float Tax_Rate = .09 better than using the actual tax rate as a literal (.09) when writing a program.

7. Give an example of a declarative statement:

8. Give an example of an imperative statement:
9. Give an example of a comment:

10. What are the three types of programs that convert programming languages into machine language?
11. Which programming paradigm is the most prominent one in today’s software development?
12. What is a variable? Why do we use them?

13. What is a data type?
14. What is a parameter?

15. How is a procedure different from a function?
16. In the code below, identify a class, an object, and a method.

class hero;
hero Max, Jeff, Rolf;
Rolf.fight;

17. Give an example of each of the following types of relationships:
a. One-to-one
b. One-to-many
c. Many-to-many

18. Discuss the importance and frequency of testing during the software development phase.

19. Describe the different types of software testing.
20. Compare and contrast the incremental and iterative models of software engineering methodologies. Give an example of each. Which is the most rigid?

21. What are the 3 different types of software documentation and what is the purpose of each?

22. Be able to identify a dataflow diagram, a use case diagram, a class diagram, and a sequence diagram.

If-then-else statements:
Show what would display in the output window. Output window:
int x = 0;
if (x <= 0) then (print “Yes”)
else (print “No”);
int x = 0;
int y = 0;
if (x <= 0) then (y = 2)
else (y = 4);
print x;
print y;
int x, y, z;
x = 2;
y = 3;
z = x + y;
if (z <= 5) then (x = x + 1; y = y + 1)
else (x = x + 2; y = y + 2);
print x;
print y;
print z;
While loop:
Show what would display in the output window. Output window:
1
2
3
4
5 int x = 0;
while (x < 3) do
(print x;
move to the next line on the screen;
x = x + 1);

• Which line of code shows the initialization step? ______
• Which line of code shows the modification step? ______
• Which line of code shows the test step? ______
• What is the termination condition for this loop (i.e. how would you get out of the loop)? _____________________________
• What is the value of x when the program finishes? ______
• Is this a pretest or a posttest loop? __________________

Repeat loop:
Show what would display in the output window. Output window:
1
2
3
4
5 int x = 0;
repeat
(print x;
move to the next line on the screen;
x = x + 2)
until (x >= 5);

• Which line of code shows the initialization step? ______
• Which line of code shows the modification step? ______
• Which line of code shows the test step? ______
• What is the termination condition for this loop (i.e. how would you get out of the loop)? _____________________________
• What is the value of x when the program finishes? ______
• Is this a pretest or a posttest loop? __________________

find the cost of your paper