Algorithms, flowcharts and pseudocode
Apréndelo jugando
Responde estas preguntas para ganar energía, luego pesca y explora. Sin cuenta.
Apuntes de la lección
What is an Algorithm?
- An algorithm is a precise sequence of instructions that solves a problem or performs a computation.
- It must be finite – it stops eventually after a finite number of steps.
- Algorithms are used as specifications for calculations and data processing.
- They can be expressed in flowcharts, pseudocode, or a programming language.
- A heuristic is a problem-solving approach without a well-defined correct result (e.g., social media recommendations).
An algorithm is a finite, unambiguous sequence of steps that turns an input into an output.

Expressing Algorithms: Flowcharts
- A flowchart uses standard symbols to show the steps of an algorithm visually.
- Oval (terminator) – start and end of the algorithm.
- Rectangle (process) – a calculation or action (e.g., 'Add 1 to count').
- Diamond (decision) – a yes/no question that branches the flow.
- Parallelogram (input/output) – reading data or displaying results.
- Arrows show the flow of control between steps.
The standard flowchart symbols - terminal, process, input/output and decision - and the same logic written as pseudocode.

Expressing Algorithms: Pseudocode
- Pseudocode is a plain-language description of an algorithm, not tied to a specific programming language.
- It uses keywords like IF, THEN, ELSE, WHILE, FOR, INPUT, OUTPUT.
- It is more precise than natural language but easier to read than code.
- Example: `IF score ≥ 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail"`.
- Pseudocode helps plan and communicate algorithms before coding.
Pseudocode keywords for input, output, assignment and selection, with the same logic drawn as a flowchart.

Tracing an Algorithm
- Tracing means manually following the steps of an algorithm with sample inputs to check it works.
- Use a trace table with columns for variables, conditions, and output.
- Record the value of each variable after every step.
- Tracing helps find logic errors and verify correctness.
- Example: trace a loop that sums numbers from 1 to 5 – track `sum` and `i`.
A trace table records one row per step: the input taken, the variable values, the decision made and any output.

Precision and Avoiding Ambiguity
- Algorithms must be unambiguous – each step has exactly one meaning.
- Vague instructions like 'add a few' are not algorithmic.
- Use clear, specific language: 'Add 1 to count' not 'increase count'.
- Flowcharts and pseudocode reduce ambiguity by using structured symbols and keywords.
- A well-defined algorithm has a clear start, finite steps, and defined output.
Steps in the wrong order give the wrong result even when every step is correct.

History of Algorithms
- Algorithms date back to ancient civilizations: Babylonian (c. 2500 BC), Egyptian (c. 1550 BC), Indian, Greek, Chinese, and Arabic.
- The Euclidean algorithm (c. 300 BC) finds the greatest common divisor.
- The Sieve of Eratosthenes (c. 240 BC) finds prime numbers.
- Al-Khwarizmi (9th century) formalized algorithms as systematic, finite steps; the word 'algorithm' comes from his name.
- Al-Kindi developed the first cryptographic algorithm using frequency analysis.
Key Takeaways
- An algorithm is a step-by-step recipe for a computer or human to follow.
- Flowcharts and pseudocode are two ways to represent algorithms.
- Always trace your algorithm to ensure it works for all inputs.
- Precision is key – avoid ambiguity.
- Algorithms are fundamental to computer science and problem-solving.
One algorithm written three ways: structured English, pseudocode and a flowchart.

Diapositivas
Sign up free to view the lesson slides
Step through every slide for this topic — plus flashcards and revision notes — with a free account.
Preguntas de práctica
Vista previa gratis — 8 de 57 preguntas. Regístrate para verlas todas.
1.What is an algorithm?
Easy- AA precise sequence of instructions to solve a problem
- BA random set of steps that may or may not work
- CA type of computer hardware
- DA programming language
2.An algorithm must always terminate (stop eventually).
EasyTrue or false?
3.Which of the following is NOT a standard flowchart symbol?
Easy- AOval
- BRectangle
- CDiamond
- DTriangle
4.In a flowchart, what does a diamond shape represent?
Easy- AA process
- BA decision
- CInput/output
- DStart or end
5.Match each flowchart symbol to its meaning.
Easy- Oval
- Rectangle
- Diamond
- Parallelogram
- Start/End
- Process
- Decision
- Input/Output
6.Pseudocode is written in a specific programming language such as Python.
EasyTrue or false?
7.Which of the following is an example of an algorithm?
Medium- AA recipe for baking a cake
- BA random guess at a number
- CA list of your favourite songs
- DA painting of a landscape
8.Arrange the following steps to make a simple algorithm for making a cup of tea:
Medium- Boil water
- Add tea bag to cup
- Pour water into cup
- Remove tea bag
Unlock all 57 questions, flashcards & more
Crea una cuenta gratis para ver todas las preguntas, las diapositivas, las tarjetas y los apuntes de repaso de este tema.