Algorithmization and Problem Solving Study Notes
Fundamentals of Algorithmization and Problem Solving
Definition of Algorithmization:
Algorithmization is a systematic methodological approach to creating software programs.
It focuses on formulating precise procedural steps required to solve a defined problem.
The output of algorithmization is an algorithm, which consists of an ordered sequence of commands describing the problem's solution.
While computer hardware and software technologies evolve rapidly, algorithmization remains invariant over time because it describes solutions at a general level, completely independent of implementation in any specific programming language.
Stages of Algorithm Construction:
Problem formulation: Clearly defining the underlying issue that needs to be solved.
Setting goals: Establishing the desired target state and output requirements.
Creation of ideas and solution strategy: Brainstorming and selecting logic to overcome the problem.
Writing created procedures: Formally recording the steps using an algorithmic language.
Verification of correctness: Testing and validating that the written procedure functions as expected.
General Strategies for Algorithm Design:
Input Data (): Represents the initial state of the problem and all starting parameters provided to the algorithm.
Output Data (): Represents the set of final states, fulfilling the desired goal or answer to the problem.
Decomposition: The strategy of breaking down a large, complex problem into smaller subproblems that are easier to analyze and solve individually.
Abstraction: The process of ignoring or concealing low-level operational details at a specific level of abstraction to focus on high-level logic.
Problem-Solving Lifecycle and the Correction Loop:
Solved problems rarely yield immediate correct solutions on the first attempt; structured decomposition into partial problems is recommended.
Problem Posing (Definition): Establishing the initial state ().
Search for Solution Methods: Exploring potential strategies ().
Selection of Solution Procedure: Choosing an optimal and correct solution path () under assumed correctness.
Execution of Selected Procedure: Performing the defined steps ().
Outcome Evaluation: Reaching the solved state ().
Correction Loop (): If executing the chosen procedure fails to eliminate the problem, adjustments and corrections must be applied. The experience gained during failed execution informs subsequent solution attempts, creating an iterative cycle between adjustments and solution discovery.

Roles in Algorithm Execution:
Procedure Discovery: Requires creative human thought. No current technical machine or automated processor possesses creative thinking capabilities to invent procedures independently.
Procedure Execution: A routine, non-creative execution of pre-defined steps. This can be delegated to a human operator or an automated hardware machine termed a processor. The processor strictly executes commands without requiring creative deliberation.
Algorithm Testing and Error Classification:
Testing vs. Verification: Testing reveals the presence of bugs but cannot prove complete correctness. Verification provides formal proof of algorithmic correctness.
Syntactic Errors: The simplest error type, consisting of typos or invalid syntax rules. Easily identified during compilation or initial parsing.
Semantic Errors: Harder to detect because individual commands are syntactically valid, but the overall sequence is unexecutable or invalid in context.
Logical Errors: The most difficult errors to identify. They stem from flaws in the underlying problem-solving logic; the program executes without crashing but yields incorrect results.
Key Properties and Formal Representation of Algorithms
Formal Definition of an Algorithm:
An algorithm is a precise set of instructions that transforms specified input data into correct output results through a finite number of steps within a finite timeframe.
Essential Properties of Algorithms:
Elementariness: The procedure consists of elementary, unambiguous operations understandable by the targeted executor/processor.
Determinism (Determinovanosť): At every stage of execution, the next action to be performed (or whether execution should terminate) is uniquely determined.
Finiteness (Konečnosť): The execution of the algorithm always terminates after a finite number of steps within a finite duration of time.
Resultativeness (Rezultatívnosť): Given the exact same set of input data, the algorithm reliably produces identical, correct output results upon completion.
Generality / Massiveness (Hromadnosť): The procedure operates on variable input parameters, enabling it to solve an entire class of similar problems rather than a single specific instance.
Efficiency (Efektívnosť): An auxiliary property focused on minimizing resource consumption (time, memory) and computational steps, which is critical when processing large volumes of data.
Taxonomy of Algorithmic Languages:
Graphical Languages:
Flowcharts (Vývojové diagramy): Use standardized geometric shapes and text to represent steps, connected by directed arrows indicating control flow.
Structuregrams (Štruktúrogramy / Nassi-Shneiderman diagrams): Composed of nested or sequential rectangular blocks representing basic algorithmic structures without explicit control lines. Unlike flowcharts, they lack official technical standardization norms.
Iconic / Picture Languages: Utilize visual image block assembly for programming (e.g., Baltík or Lego RCX block programming in LabVIEW).
Textual Languages:
Programming Languages: Formalized computer languages with strictly defined syntax and grammar rules designed for machine execution.
Verbal Description (Natural Language Pseudocode): Standardized, non-ambiguous natural language phrasing used to describe algorithms without conversational vagueness.
Decision Tables (Rozhodovacie tabuľky): Tabular specifications mapping combinations of input variable values directly to targeted actions without detailing step-by-step execution sequences.
Data Objects, Commands, and Variable Types
Input and Output Commands:
Input Command: Reads a specific value from an input device (e.g., keyboard) and assigns it to a memory variable.
Syntax:
CITAJ(A);— Reads one input value and assigns it to variableA.Example:
CITAJ(VEK);— Waits for user keyboard entry; upon pressing Enter, stores the entered numeric value in memory under identifierVEK.Output Command: Displays stored values or results from computer memory to an output device (e.g., screen).
Syntax:
PIS(PRIEMER);— Displays the current value stored in variablePRIEMER.Text literals: Enclosed within single apostrophes
'...'.Formatted combined output:
PIS('PRIEMER ZIAKOV JE: ', PRIEMER);outputs literal string text followed by the value of variablePRIEMER(e.g., displayingPRIEMER ZIAKOV JE: 1,99).
Classification of Program Statements and Objects:
Simple Commands: Single, atomic statements.
Compound Commands: Sequences of multiple commands separated by semicolons
;.Variables: Named memory objects whose value can dynamically change during execution, though holding a single specific value at any given instant.
Constants: Immutable memory objects retaining a static value throughout execution.
Assignment Statement: Action assigning a explicit value or evaluated result of an expression directly to a target variable using the assignment operator
:=(e.g.,).Expressions: Prescriptions used to calculate or obtain a specific scalar value.
Variable Data Types:
Integer (
celočíselná): Restricts variable value domain strictly to whole numbers (\bbf{Z}).Character (
znaková): Contains single text characters or multi-character text strings.Real (
reálna): Restricts variable domain to real floating-point values (\bbf{R}).Boolean / Logical (
logická): Holds binary truth values:true(pravda) orfalse(nepravda).
Identifiers and Declaration Section:
Variable Identifiers: Alphanumeric character strings used to name variables; must always begin with an alphabetic letter.
Declaration Section: An explicit initial section located at the beginning of an algorithm/program specifying all internal objects, identifiers, and assigned data types prior to executive logic.
Expression Types and Operators:
Arithmetic Expressions: Constructed from numeric operands, round parentheses
(), and arithmetic operators (+,-,*,/).Integer Division Functions:
DIV: Returns the integer quotient of division (truncating decimals).MOD: Returns the integer remainder of division.Example: For and , and .
Logical Expressions: Built from logical operands and operators:
Conjunction (