Learn Together Algorithm p.1
Introduction
This is a new blog post series about algorithms. I'm new to this topic, and I want to learn together with you, and of course, pass my next exam in university. :)
Algorithms:
- Definition: A set of ordered elementary operations that are unambiguous and computable, so that when we run it with a specific input, we get a specific output and stop in a finite time.
Key Points of the Algorithm:
- Ordered operations -> The operations must be in a specific, clear order.
- No ambiguity -> The operations must be clear and unambiguous.
- Computable -> The operations must be computable.
- Finiteness -> A finite number of operations, a finite number of inputs, and completion in a finite time.
Resolution Process:
- Analyze the computational problem -> What input do we start with? What output do we want? What are the constraints? Desired properties?
- Design the algorithm -> Find an approach to solve the problem and write it in natural language or use a flowchart.
- Implement the algorithm -> Use a programming language.
- Test the algorithm -> Test the algorithm with different inputs; if the output is not as expected, we need to go back to step 2.
Desired Properties:
- Correctness -> All instances should complete with the correct output.
- Generality -> The algorithm should be applicable to a specific group of problems.
- Determinism -> If we take the same input, we should get the same output.
- Efficiency -> The algorithm should be efficient in terms of cost.
Structured Programming:
-
Definition: A programming paradigm that allows writing programs in a structured way.
-
Key Points:
- Sequence -> The operations are executed in a specific order.
- Selection -> The operations are executed only if a specific condition is true.
- Repetition -> The operations are executed multiple times.
Useful for Writing the Algorithm in a Structured Way.
Block Descriptions:
Example -> Calculation of the Factorial:
Introduction to Computational Thinking
Computational thinking is a problem-solving process that relies on several key principles. These allow problems to be formulated in a way that enables a computer to solve them:
- Problem formulation: Representing problems in a form that allows the use of a computer to solve them.
- Logical organization of data: Representing information through encoding, data structures, and efficient processes.
- Abstraction and modeling: The ability to ignore irrelevant details and focus on the most important aspects of the problem.
- Problem decomposition: Breaking down complex problems into simpler sub-problems (a "divide and conquer" approach).
- Pattern recognition: The ability to identify recurring structures.
- Inductive and deductive reasoning: The ability to extract general rules from specific examples and draw conclusions from given premises.
- Algorithms: The concept of well-defined procedures to achieve results from given inputs.
- Automation: The idea that systems can control processes automatically.
- Interaction and testing: The ability to interact with devices and verify their functionality.
- Causality (cause-effect relationships): The idea that actions lead to corresponding effects.