(1) Programming Fundamentals: Algorithms

(1) Programming Fundamentals: Algorithms

Design and development of algorithms play a crucial role in the field of computer science and problem-solving. Algorithms are the backbone of any software system, providing a systematic approach to solving complex problems and achieving specific tasks. They are essential tools for transforming abstract concepts into practical solutions

Algorithms

An algorithm is a finite set of clear and precise instructions or steps that are followed to solve a problem or perform a specific task. It is a logical sequence of actions that are executed in a determined order to achieve a predefined goal. Algorithms are used in various areas such as computer science, mathematics, engineering, and everyday life to provide effective and efficient solutions to problems.

Characteristics of an algorithm

Algorithms possess key characteristics that make them effective problem-solving tools. Those are:

  • Precision: Algorithms must be specific and detailed, avoiding ambiguities and allowing a unique interpretation of each step.
  • Finite: An algorithm must have a finite number of steps and eventually reach its end or result.
  • Defined: Each instruction in an algorithm must be clear and not open to multiple interpretations. Given an initial state, an algorithm will always produce the same result.

Examples of algorithms in everyday life

Algorithms, often associated with complex computational processes, are not limited to the realm of computer science. In fact, they can be found in our everyday lives, guiding us through various tasks and routines. Here are some telling examples:

  • Cooking recipe: A recipe is a common example of an algorithm in everyday life. It follows a sequence of clear and precise steps to prepare a specific dish. Each step indicates the actions to be performed, such as cutting ingredients, mixing, cooking at a specific temperature, etc.
  • Navigation instructions: When using a navigation app on a mobile device, algorithms are followed that provide step-by-step instructions to reach a destination. These algorithms consider the current location, the desired destination, and the best available routes.
  • Morning routine: Even daily routines can be considered algorithms. For example, a morning routine may include steps such as waking up at a specific time, getting out of bed, brushing teeth, showering, getting dressed, and having breakfast.

Representation of algorithms

Now you know a little bit about algorithms you may wonder how this is translated into something real. For this we use representations like definition languages and diagrams. Some of those representations are:

  • Flowchart: It is a type of graphical representation that uses symbols and arrows to show the sequence of steps in an algorithm. Each symbol has a specific meaning, and the arrows indicate the direction of flow.
What is a Flowchart
The ultimate guide to understanding flowcharts including history, common uses and helpful how-to instructions. Sign up is free!

More about flowcharts

  • N-S Diagram (Nassi-Schneiderman): It is another form of graphical representation that uses control structures such as rectangular blocks, diamonds, and arrows to represent the sequence, selection, and repetition of steps in an algorithm. This type of diagram is known for its clarity and readability. But to be honest, I have never seen it outside the academics boundaries.
3GL Program Design - Nassi-Schneiderman Diagrams
Example of a N-S diagram
  • Pseudocode: It is a language for algorithm specification that uses a combination of natural language and programming elements to describe the steps of an algorithm. Although not tied to a specific programming language, pseudocode follows a logical structure and allows for clear expression of the steps to be followed.
Example of Pseudocode
  • Natural language: Algorithms can also be described in natural languages such as Spanish or English. In this case, phrases and sentences are used to explain the steps of the algorithm in a way that is understandable to humans.
  • Formulas: In some cases, algorithms may be based on mathematical or scientific formulas. These formulas represent specific relationships and calculations that need to be performed to solve a problem or achieve a desired result.
Formula to get the sum of the first n numbers

Conclusion

Algorithms are fundamental tools in computer science and problem-solving, providing a systematic approach to solving complex problems and achieving specific tasks.

They are characterized by precision, finiteness, and well-defined instructions and they can be found in various aspects of everyday life. In the next posts we are going to work with algorithms using one of its representations: Pseudocode. So subscribe and don't miss it!


If you enjoy the content, please don't hesitate to subscribe and leave a comment! I would love to connect with you and hear your thoughts on the topics I cover. Your feedback is greatly appreciated!