Learn Algorithm 1

October 11, 2024

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:

  1. Ordered operations -> The operations must be in a specific, clear order.
  2. No ambiguity -> The operations must be clear and unambiguous.
  3. Computable -> The operations must be computable.
  4. Finiteness -> A finite number of operations, a finite number of inputs, and completion in a finite time.

Resolution Process:

  1. Analyze the computational problem -> What input do we start with? What output do we want? What are the constraints? Desired properties?
  2. Design the algorithm -> Find an approach to solve the problem and write it in natural language or use a flowchart.
  3. Implement the algorithm -> Use a programming language.
  4. 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:

  1. Correctness -> All instances should complete with the correct output.
  2. Generality -> The algorithm should be applicable to a specific group of problems.
  3. Determinism -> If we take the same input, we should get the same output.
  4. 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:

    1. Sequence -> The operations are executed in a specific order.
    2. Selection -> The operations are executed only if a specific condition is true.
    3. Repetition -> The operations are executed multiple times.

Useful for Writing the Algorithm in a Structured Way.

Block Descriptions:

diagram blocks

Example -> Calculation of the Factorial:

flowchart 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:

  1. Problem formulation: Representing problems in a form that allows the use of a computer to solve them.
  2. Logical organization of data: Representing information through encoding, data structures, and efficient processes.
  3. Abstraction and modeling: The ability to ignore irrelevant details and focus on the most important aspects of the problem.
  4. Problem decomposition: Breaking down complex problems into simpler sub-problems (a "divide and conquer" approach).
  5. Pattern recognition: The ability to identify recurring structures.
  6. Inductive and deductive reasoning: The ability to extract general rules from specific examples and draw conclusions from given premises.
  7. Algorithms: The concept of well-defined procedures to achieve results from given inputs.
  8. Automation: The idea that systems can control processes automatically.
  9. Interaction and testing: The ability to interact with devices and verify their functionality.
  10. Causality (cause-effect relationships): The idea that actions lead to corresponding effects.

See you in the next post! Stay Tuned!