Algorithm Basics – Formulating, Applying, Pseudocode & Control Structures
This post is a conceptual explanation of algorithms – including exam questions and tags.
In a Nutshell
An algorithm is a clear set of instructions to solve a problem in finitely many steps.
Compact Technical Description
An algorithm describes a systematic sequence of instructions to solve a problem or perform a task. It must be unambiguous, finite, executable, and deterministic. In application development, algorithms are essential for problem-solving and data processing. Formulation can be done in natural language, pseudocode, structure diagrams, or flowcharts. When applying an algorithm, efficiency in terms of time and memory is crucial.
Exam-Relevant Key Points
- An algorithm consists of finitely many well-defined instructions
- Formulations in pseudocode or as structure diagrams are typical in exams
- Linear, branching, and repetitive structures are fundamental control structures
- Runtime complexity is important for evaluating efficiency
- Application of typical algorithms: sorting, searching, calculating
Core Components
- Unambiguity – each instruction is clearly defined
- Finiteness – the algorithm must end after finitely many steps
- Executability – each step can be executed with available means
- Determinism – the same input always produces the same output
- Structure – use of control structures (sequence, selection, repetition)
Practical Example
// Example: Linear Search (Pseudocode)
FOR i FROM 0 TO n-1
IF array[i] == searchvalue
RETURN i
RETURN -1
Explanation: The algorithm searches an array sequentially and returns the index of the first found search value, otherwise -1.
Typical Exam Questions (with Short Answer)
- What is an algorithm? A clear, finite sequence of instructions to solve a problem.
- Essential properties of an algorithm? Unambiguity, finiteness, executability, determinism, structure.
- Pseudocode? Informal, language-independent description of an algorithm, easily convertible into code.
- Three control structures? Sequence, selection (condition), repetition (loop).
- How does linear search work? Traverses each element of an array in order and checks for equality with the search value.
- Recursive vs. iterative solution? Recursive solutions call themselves, iterative solutions use loops.
- Evaluate the efficiency of an algorithm? Through analysis of runtime and space complexity (e.g., Big O notation).
Most Important Sources
- https://www.informatik-lexikon.de/algorithmus/
- https://www.gut-erklaert.de/algorithmen-datenstrukturen.html
- https://www.programmierenlernenhq.de/algorithmen/