next topic
  
back to Rev 1 index
Topic 4
Principles of algorithm design.
- Define the problem:
Identify what is required for the problem using the IPO model:
- Information that needs to be collected (input)
- Steps that need to be executed to produce the required output (process)
- Information that needs to be displayed in the required format (output)
- Outline the solution:
After identifying the requirements for the problem, break the problem into smaller tasks and
develop an outline of the solution.
The outline may include:
- The major steps involved
- The order in which those steps occur (sequence)
- The steps that need to be repeated (repetition)
- The steps that involve a choice between alternatives (selection)
- Information that needs to be collected and stored (variables and constants)
- Develop the outline into an algorithm:
The outline of the solution developed in step 2 is then expanded into an algorithm.
Algorithm is a set of steps that need to be followed for solving the problem.
The algorithm can be developed either in text form (pseudo code) or in a diagram (flowchart)
- Test the algorithm for correctness:
This step is one of the most important in the development of the program.
This step involves testing the algorithm to ensure it provided the solution for the problem.
This step also involves identifying any major logic errors with algorithm early on so they can easily be resolved.
Check the algorithm for the following:
- All information required is collected and stored in the required format (input)
- All the processing steps follow logically from one to another (sequence)
- All the processing steps required to be repeated, do repeat and eventually terminate (repetition)
- All the processing steps that involve a choice between alternatives allows the user to traverse any (or all) of the allowable paths, and that no path is omitted, or leads to a dead-end program-wise (selection)
- All information required is displayed in the required format with the desired and expected results (output)
- Code the algorithm into a specific programming language:
After all design considerations in the previous four steps have been met, the code is written for the algorithm using the chosen programming language.
- Run the program on the computer:
Use a program to execute the code for syntax errors and logic errors.
If the program has been well designed, the code should solve the problem without any issues.
If the problem has not been solved, revisit the previous steps:
- Is there a problem with your logic and design?
- Is there a problem with your code and implementation?
- Are there any errors in the program that may give you some clues as to where the errors lie?
This step may need to be repeated several times until the program eventually solves
the problem with desired and expected results.
- Document and maintain the program:
With this step, documentation should be an ongoing process from the initial definition of the problem to the final test result of the program.
Documentation should contain the following information:
- Instructions for running the program
- Inputs that can be entered for the program
- The expected output(s) for the program
- Problems discovered with the program
- Steps for resolving the problems with the program
Documentation may be stored as both external documentation (flowchart, pseudo code and user manual) and internal documentation (commenting of the code).
next topic
 
 
back to Rev 1 index