What is an algorithm?
Algorithms are one of the four cornerstones of Computer Science. An algorithm is a plan, a set of step-by-step instructions to solve a problem. If you can tie shoelaces, make a cup of tea, get dressed or prepare a meal then you already know how to follow an algorithm.
In an algorithm, each instructionA single action that can be performed by a computer processor. is identified and the order in which they should be carried out is planned. Algorithms are often used as a starting point for creating a computer program, and they are sometimes 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..
If we want to tell a computer to do something, we have to write a computer program that will tell the computer, step-by-step, exactly what we want it to do and how we want it to do it. This step-by-step program will need planning, and to do this we use an algorithm.
Computers are only as good as the algorithms they are given. If you give a computer a poor algorithm, you will get a poor result 鈥 hence the phrase: 鈥楪arbage in, garbage out.鈥
Algorithms are used for many different things including calculations, data processing and automation.
Making a plan
It is important to plan out the solution to a problem to make sure that it will be correct. Using computational thinkingA problem-solving method using computer science techniques, where possible solutions are developed and presented in a way that can be understood by humans and computers. and decompositionThe breaking down of a system into smaller parts that are easier to understand, program and maintain. we can break down the problem into smaller parts and then we can plan out how they fit back together in a suitable order to solve the problem.
This order can be represented as an algorithm. An algorithm must be clear. It must have a starting point, a finishing point and a set of clear instructions in between.