program design. the design process how do you go about writing a program? –it’s like many other...
TRANSCRIPT
Program Design
The design process
• How do you go about writing a program?– It’s like many other things in life
• Understand the problem to be solved• Develop a plan of attack (we call this the
algorithm)• Execute your plan of attack (write the program)
Problem Algorithm Implementation
Problem solving phase Implementation phase
Algorithm
• A sequence of precise instructions which leads to a solution is called an algorithm.– Ex: compute the product of two integers
– Input two numbers, e.g., N1 and N2– Product, P, initially set to 0– Add the first number, i.e. N1, to P– Decrement N2– Check whether N2 is 0 or not– If N2 is 0, output P and stop– If not, repeat these steps starting at the addition above
Algorithms• The biggest error you can make in
computer programming– Skipping the “Develop the Algorithm” phase– Sometimes hard to see with the simple
programs in this course, but with more difficult programs jumping right to the implementation is unwise
Problem ImplementationAlgorithm
Program Design