|
|
|
|
|
|
|
2. General Solution (Algorithm). Develop a logical sequence of steps to be used to solve the problem. |
|
|
|
|
|
|
|
|
3. Verify. Follow the steps exactly to see if the solution really does solve the problem. |
|
|
|
|
|
|
|
|
1. Concrete Solution (Program). Translate the algorithm into a programming language. |
|
|
|
|
|
|
|
|
2. Test. Have the computer follow the instructions. Then manually check the results. If you find errors, analyze the program and the algorithm to determine the source of the errors, and then make corrections. |
|
|
|
 |
|
|
|
|
Once a program has been written, it enters a third phase: maintenance. |
|
|
|
|
|
|
|
|
2. Maintain. Modify the program to meet changing requirements or to correct any errors that show up in using it. |
|
|
|
|
|
|
|
|
Each time the program is modified, it is necessary to repeat the problemsolving and implementation phases for those aspects of the program that change. Together, the problem-solving, implementation, and maintenance phases constitute the program's life cycle. |
|
|
|
|
|
|
|
|
A computer is not intelligent. It cannot analyze a problem and come up with a solution. The programmer must analyze the problem, arrive at the solution, and then communicate it to the computer. What's the advantage of using a computer if it can't solve problems? Once we have a solution for a problem and have prepared a version of it for the computer, the computer can repeat the solution very quickly and consistently, again and again. The computer frees people from repetitive and boring tasks. |
|
|
|
|
|
|
|
|
The programmer begins the programming process by analyzing the problem and developing a general solution called an algorithm. Understanding and analyzing a problem take up much more time than Figure 1-1 implies. They are the heart of the programming process. |
|
|
|
 |
|
 |
|
|
Algorithm A step-by-step procedure for solving a problem in a finite amount of time. |
|
|
|
|
|
|
|
|
If our definitions of a computer program and an algorithm look similar, it is because all programs are implementations of algorithms. A program is simply an algorithm that has been written for a computer. |
|
|
|
|
|
|
|
|
An algorithm is a verbal or written description of a logical sequence of actions. We use algorithms every day. Recipes, instructions, and directions are all examples of algorithms that are not programs. |
|
|
|
|
|