Course Introduction to Programming
Representation Forms
In this lesson, we will deepen our knowledge of Algorithm Representation, exploring the different ways to express a program's logic in a clear and structured manner.
We will learn how to use flowcharts to visualize processes, pseudocode to describe algorithms in a detailed and sequential way, and how to identify the necessary steps to solve computational problems efficiently and organizedly.
Why represent an algorithm?
Representing an algorithm is like creating a plan or a draft. This allows the logic to be discussed, planned, and validated before the code is actually written. Furthermore, programming languages have different rules, so a neutral representation (pseudocode, flowchart, or narrative description) allows anyone to understand the idea, even without knowing a specific language. Finally, the use of algorithms facilitates the detection of logical errors and helps in dividing the problem into smaller steps, making teamwork more efficient, where everyone discusses the same plan before implementing it.
Types of description
1. Narrative description.
It is the explanation of the algorithm in natural language (plain language). It is useful for communicating the idea simply and quickly; it does not require syntax details, it just describes the steps.
- Advantages: very accessible; easy to write.
- Disadvantages: can be ambiguous / not precise enough for direct implementation.
Example of Narrative Description: Algorithm to calculate a student's average
- Write down the first grade;
- Write down the second grade;
- Calculate the arithmetic mean of the grades;
- If the average is greater than or equal to 7, the student is approved;
- If the average is less than 7 but greater than or equal to 4, the student is on final assessment;
- If the average is less than 4, the student is failed;
2. Pseudocode.
It is a semi-formatted representation that mixes natural language and code-like structures (variables, conditions, input/output commands). It serves as a bridge between the idea and the actual code: translating pseudocode into a language is usually straightforward.
- Advantages: does not require rigid syntax, easy to transform into code.
- Disadvantages: it does not have rigid syntax rules, which can lead to ambiguity or different interpretations among people.
- Recommendations: use indentation and descriptive variable names.
Pseudocode Example: Algorithm to calculate a student's average
- Variables: Grade1, Grade2, Average
- Read(Grade1, Grade2)
- Average = (Grade1+Grade2)/2
- If (Average >= 7) Print "Student is approved"
- If (Average < 7 and Average >= 4) Print "Student is on assessment"
- If (Average <= 4) Print "Student is failed"
3. Flowchart.
The Flowchart uses a graphical representation. The algorithm's representation is made using geometric shapes and a brief description of which action is associated with each shape. You can use sites like: Lucidchart and Draw.io to build your own flowcharts ๐
 Advantages: easy to understand visually; great for presentations and for those who prefer to see the flow.
 Disadvantages: can become large for complex algorithms.
Shapes used:
- Start and end of algorithm: 
 
- Data input and output: 
 
- Decision: 
 
- Process: 
 
Flowchart Example: Algorithm to calculate a student's average using a flowchart.
โ ๏ธ Note that a different type of shape is used for each type of action.
Conclusion
Throughout this lesson, you have deepened your knowledge of algorithm representation, learning to express the logic of programs in a clear and organized way. We explored different forms of description: narrative, pseudocode, and flowcharts, understanding their advantages, disadvantages, and practical applications.
Now you know how to plan and visualize algorithms before coding them, ensuring the logic is correct and facilitating communication among team members ๐
