Designing an algorithm
An algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs. is a plan, a logical step-by-step process for solving a problem. Algorithms are normally written as a flowchartA diagram that shows a process, made up of boxes representing steps, decision, inputs and outputs. or in pseudocode Also written as pseudo-code. A method of writing up a set of instructions for a computer program using plain English. This is a good way of planning a program before coding..
The key to any problem-solving task is to guide your thought process. The most useful thing to do is keep asking 鈥榃hat if we did it this way?鈥 Exploring different ways of solving a problem can help to find the best way to solve it.
When designing an algorithm, consider if there is more than one way of solving the problem.
When designing an algorithm there are two main areas to look at:
- the big picture - What is the final goal?
- the individual stages 鈥 What hurdles need to be overcome on the way to the goal?
Understanding the problem
Before an algorithm can be designed, it is important to check that the problem is completely understood. There are a number of basic things to know in order to really understand the problem:
- What are the inputData which is inserted into a system for processing and/or storage. into the problem?
- What will be the outputData which is sent out of a system. of the problem?
- In what order do instructionA single action that can be performed by a computer processor. need to be carried out?
- What decisions need to be made in the problem?
- Are any areas of the problem repeated?
Once these basic things are understood, it is time to design the algorithm.