Algorithms are a methodical and accurate description of how to solve a problem. The definition of an algorithm is a step-by-step procedure of well-defined executable instructions designed to perform a task or solve a problem.
An algorithm has many similarities to a program where the major difference is that we can describe algorithms regardless of program language. An algorithm can be seen as a job description on how to solve the problem. It describes steps the program should take. It is important to remember that there are usually many algorithms to solve a problem and that it is important trying to find the simplest and most effective solution to the problem.
For simpler problem solving, you can manage by having your algorithm in your head but as the difficulty and complexity of the tasks increase, it is almost necessary to think through the algorithm carefully before you start coding. So a good tip is to have a habit of drawing / writing down the solution process for the task.
Pseudocode is a way to describe an algorithm without using programming. Psedocode is therefore not a real program language (like for example Python), but a way of describing an algorithm with, for example, text or flow charts. We use pseudocode to get a better overview of how the program works and make it easier to explain the algorithm.
When drawing algorithms, you usually use so-called flowcharts that help you show what kind of action the program should perform and when. The three most common symbols in a flow chart and when they are used:
To the right, we will see a simple example of an algorithm for a thermometer that will check the temperature. If the temperature is below a certain limit, the radiator must be started.
1. The algorithm starts by starting the thermometer.
2. The thermometer then checks to see what the temperature is.
3. Is it below 10 degrees? If yes, then the radiator should be started and the algorithm terminated.
4. If no, a delay of 30 minutes should be initiated and then the algorithm restarted at step 2.