Chapter 3 Flashcards
What is an algorithm?
A finite set of step-by-step instructions that specifies a process of moving from the initial situation to the final situation.
What 5 things make up a good algorithm?
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
Define stepwise refinement
It is a method of constructing algorithms that decomposes a complex algorithm into smaller, simpler algorithms.
Programs using stepwise refinement are:
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.
Define Pseudocode
Combies naturalness of natural language with the structure of a programming language
What 4 benefits do we get from using pseudocode
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
4 Types of accesor methods + description
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
What is a helper method?
Small methods that are created to help and reduce code in another method. They can be called patterns.
What is a stub?
A method that has just enough code to compile but not actually to do its job.
What are 3 benefits of a stub?
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
Define top-down design
Another name for stepwise refinement, you start at the top method and work down to all the helper methods.
What 3 things make a program easy to understand?
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