|
|
|
|
|
|
|
Figure 1-16
Building-Block Approach |
|
|
|
|
|
|
|
|
collect all of the information about data and results into one place for easy reference. Then you can see the beginning and ending states necessary for means-ends analysis. |
|
|
|
|
|
|
|
|
Most mental blocks are caused by not really understanding the problem. Rewriting the problem in your own words is a good way to focus on the subparts of the problem, one at a time, and to understand what is required for a solution. |
|
|
|
|
|
|
|
|
Algorithmic Problem Solving |
|
|
|
|
|
|
|
|
Coming up with a step-by-step procedure for solving a particular problem is not always cut-and-dried. In fact, it is usually a trial-and-error process requiring several attempts and refinements. We test each attempt to see if it really solves the problem. If it does, fine. If it doesn't, we try again. You typically use a combination of all of the techniques we've described to solve any nontrivial problem. |
|
|
|
|
|
|
|
|
Remember that the computer can only do certain things (see p. 13). Your primary concern, then, is how to make the computer transform, manipulate, calculate, or process the input data to produce the desired output. If you keep in mind the allowable instructions in your programming language, you won't design an algorithm that is difficult or impossible to code. |
|
|
|
|
|
|
|
|
In the case study below, we develop a program for calculating employees' weekly wages. It typifies the thought processes involved in writing an algorithm and coding it as a program, and it shows you what a complete C++ program looks like. |
|
|
|
|
|