COMPUTER PROGRAMMING – 4. Algorithms
What is an algorithm?
An algorithm is a sequence of instructions that are followed to complete a task. This task can be anything, as long as you can give precise, step-by-step instructions for it.
Algorithms exist all around us. A recipe for baking a cake can be considered a type of algorithm. It tells us what ingredients are needed to bake the cake and what steps to follow.
There is usually more than one way to solve a problem. There may be many different recipes to bake a cake, but all of them end up tasting the same when followed. The same is true for algorithms.
Pseudocode is a form of code that is written for humans, not computers, to read. It is often written to show how an algorithm works.
Computing text books often use pseudocode in their examples so that all programmers can understand them, even if they do not all know the same programming languages.
A flowchart is a diagram that represents a set of instructions. Flowcharts normally use standard symbols to represent the different types of instructions. These symbols are used to construct the flowchart and show the step-by-step solution to the problem. Flowcharts can be used to plan out programs.
In the flowchart below, the program uses an input box to ask a user to input if it is raining. It then uses a decision box to make a choice – to decide what to do next.
If the answer to the question is ‘no’ then it tells you to leave the umbrella at home. If the answer is ‘yes’, it tells you to take an umbrella.
Whether you have written your algorithm as pseudocode or drawn it as a flowchart, it will next need to be translated into code which the computer will then follow to complete a task.
This code is written in a programming language. There are many different types of programming languages. Some that you may come across are Scratch, Logo, Blockly, Python and Kodu. On this website, we will mostly look at Scratch.
Follow this hyperlink to learn more:-