Chapter 3 Flashcards

1
Q

What is an algorithm?

A

A finite set of step-by-step instructions that specifies a process of moving from the initial situation to the final situation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What 5 things make up a good algorithm?

A

1) Correct
2) Easy to read and understand
3) Easy to debug
4) Easy to modify to solve variations of the original task
5) Efficient

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define stepwise refinement

A

It is a method of constructing algorithms that decomposes a complex algorithm into smaller, simpler algorithms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Programs using stepwise refinement are:

A

1) Easy to understand
2) Free of errors
3) Easy to test and debug
4) Easy to modify
5) Imposes a structure on the problem
6) Can think at a higher level of abstraction.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define Pseudocode

A

Combies naturalness of natural language with the structure of a programming language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What 4 benefits do we get from using pseudocode

A

1) Helps us think more abstractly
2) Allows us to trace our programs very early in development
3) Can provide a common language on a developement team
4) Can be implemented in a variety of programming languages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

4 Types of accesor methods + description

A

1) Public - any method can access from any class
2) Protected - can be called from any method from the same class or sublcass
3) Private - May be only called withing the same class
4) Package - may be called from the same package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a helper method?

A

Small methods that are created to help and reduce code in another method. They can be called patterns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a stub?

A

A method that has just enough code to compile but not actually to do its job.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are 3 benefits of a stub?

A

1) They serve as placeholders for work that still must be completed
2) Allows the code to compile even though its not finished.
3) A compiled program can run with may allow some early testing to be performed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define top-down design

A

Another name for stepwise refinement, you start at the top method and work down to all the helper methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What 3 things make a program easy to understand?

A

1) Each method including the main method is composed of a few easily understoo statments.
2) Each method has a single, well defined purpose
3) Each method can be understood by examining the statements it contains

How well did you know this?
1
Not at all
2
3
4
5
Perfectly