What is an Algorithm in Programming?

An algorithm is a rewritten, well-defined, sequential, and finite set of instructions or rules that allow an activity to be executed in sequential steps for the person performing it in related fields such as Mathematics and Computer Science.

Algorithm Definition, Features and Types

What is an Algorithm, and What are its Types and Features?

Given an initial state and an input, following successive steps, a final state is reached, and a solution is obtained.

History

The word algorithm comes from Muḥammad ibn Mūsā al-Khwārizmī, a 9th-century Arab mathematician originally from the ancient city of Khowarism located in the USSR. The famous mathematician was able to formulate the rules for four multi-step arithmetic operations.

Later, this formula was generally used to determine the sequences of operations that lead to the solution of any mathematical task.

As time passed, the process of searching and formalizing algorithms was not just a task for mathematicians, but different types of algorithms began to emerge.

Thus, an algorithm emerged for games such as checkers and chess involving shapes and positions where it is necessary to choose the next step of the objects.

These are the actions of an electric current or a specific machine, or, for example, the search algorithm for a word in a dictionary using texts.

However, it should be noted that, in any case, algorithms do not work with real-world objects but with their representations and abstractions. Therefore, variables, symbols, and encodings are used to denote them.

Algorithm Features

An algorithm is also used to solve problems many times in everyday life. For example, manuals show algorithms for using a device or instructions an employee receives from their employer.

Examples of algorithms used in mathematics are the division algorithm to calculate the division of two numbers, the Euclidean algorithm to obtain the largest common divisor of two positive integers, and the Gaussian method to solve a system of linear equations.

In general, there is no strict consensus on the official definition of an algorithm. Many authors refer to them as lists of instructions for solving an abstract problem, that is, the finite number of steps that transform a problem’s data into a solution.

However, it should be noted that some algorithms do not have to finish or solve a particular problem. For example, a modified version of the Eratosthenes sieve that never finishes calculating prime numbers is still an algorithm.

Throughout history, many authors have tried to explain using mathematical models and algorithms such as Turing machines.

However, these models are subject to certain types of data, such as numbers, symbols, or graphs. However, algorithms generally work on large amounts of data structures.

In general, the standard part in all definitions can be divided into three unless we consider parallel algorithms.

1. Sequential Time

An algorithm runs step-by-step in discrete time, thus defining a set of computational situations for each valid input.

2. Abstract State

Each computational situation can be defined using the first-order structure, and each algorithm is independent of its implementation. Thus, first-order structures in an ALG are invariant under isomorphism.

3. Bounded State

A wholly fixed and finite definition determines the transition from one state to another. In short, between each state and the next, only a fixed and finite number of terms of the current state can be considered.

In short, an algorithm is a solution method that works step by step, where each step can be clearly defined without reference to a specific computer, and also has a fixed limit for the amount of data that can be read/written in one step.

This broad definition can cover both practical algorithms and those that only work in theory. For example, Newton’s method and Gauss-Jordan elimination work infinitely, at least in principle. However, it is not possible to program an endless process on a computer.

In particular, Arithmetic can be considered as a fourth feature that can be used to verify that every computable function can be programmed in a Turing machine. In the first step, only computable transactions cannot be processed.

Algorithm Expression Methods

An algorithm can be done in many ways, including natural language, pseudocode, flowcharts, and programming languages.

Natural language descriptions tend to be vague and lengthy. However, using pseudocode and flowcharts removes many natural language ambiguities.

These expressions are more structured ways to represent ALGs. However, they remain independent of a particular programming language.

The description of an algorithm is usually made in high-level expression, form, and application.

In the high-level description, the problem is set up, a mathematical model is chosen, and the algorithm is verbally explained with pictures and details. If an element is greater than the maximum, its value is assigned to the maximum.

To find the maximum element, the value of the first element is assumed to be maximum. Each value is then compared with the value of the maximum number found so far.

In figural expression, pseudocode is used to describe the sequence of steps that find the solution.

In the implementation method, some objects that can perform the algorithm or commands expressed in a particular programming language are shown. It is also possible to include a theory that indicates that it is correct, the complexity analysis, or both.

Algorithm Diagrams

Flowchart

Flowcharts are graphic descriptions of ALGs. They use symbols associated with arrows to indicate the order of instructions and are governed by the ISO.

They are used to represent small ALGs because they take up a lot of space and are somewhat challenging to create.

Because of their ease of reading, they are used as an introduction to ALGs, a description of a language, and a description of processes to people outside of computing.

Structured Rectangular Diagrams

One of the challenges of flowcharts is that they provide the possibility to illustrate the flow of the solution to a problem graphically.

An erratic programmer misplacing the flow arrows can eventually lead to a more complex situation than the idea itself. In another case, it allows using graphical tools to represent the solution to a problem.

It is based on representing the entire algorithm in a rectangular frame. Unlike the previous technique, it basically uses three symbols corresponding to each of the basic structures of programming logic.

Pseudocode

Pseudocode is a method that looks like a programming language but has some natural language rules. It represents particularly complex instructions as it has many advantages over flowcharts. Also, it is not subject to any standard.

Pseudocode has a group of keywords and symbols that make up the vocabulary to represent the actions of this technique for computational.

An algorithm (ALG) is a rewritten, well-defined, sequential, and finite set of instructions or rules that allow an activity to be executed in sequential steps for the person performing it in related fields such as Mathematics and Computer Science.

Algorithm Definition, Features and Types

What is an Algorithm, and What are its Types and Features?

Given an initial state and an input, following successive steps, a final state is reached, and a solution is obtained.

History

The word algorithm comes from Muḥammad ibn Mūsā al-Khwārizmī, a 9th-century Arab mathematician originally from the ancient city of Khowarism located in the USSR. The famous mathematician was able to formulate the rules for four multi-step arithmetic operations.

Later, this formula was generally used to determine the sequences of operations that lead to the solution of any mathematical task.

As time passed, the process of searching and formalizing algorithms was not just a task for mathematicians, but different types of algorithms began to emerge.

Thus, an algorithm emerged for games such as checkers and chess involving shapes and positions where it is necessary to choose the next step of the objects.

These are the actions of an electric current or a specific machine, or, for example, the search algorithm for a word in a dictionary using texts.

However, it should be noted that, in any case, algorithms do not work with real-world objects but with their representations and abstractions. Therefore, variables, symbols, and encodings are used to denote them.

Algorithm Features

An algorithm is also used to solve problems many times in everyday life. For example, manuals show algorithms for using a device or instructions an employee receives from their employer.

Examples of algorithms used in mathematics are the division algorithm to calculate the division of two numbers, the Euclidean algorithm to obtain the largest common divisor of two positive integers, and the Gaussian method to solve a system of linear equations.

In general, there is no strict consensus on the official definition of an algorithm. Many authors refer to them as lists of instructions for solving an abstract problem, that is, the finite number of steps that transform a problem’s data into a solution.

However, it should be noted that some algorithms do not have to finish or solve a particular problem. For example, a modified version of the Eratosthenes sieve that never finishes calculating prime numbers is still an algorithm.

Throughout history, many authors have tried to explain using mathematical models and algorithms such as Turing machines.

However, these models are subject to certain types of data, such as numbers, symbols, or graphs. However, algorithms generally work on large amounts of data structures.

In general, the standard part in all definitions can be divided into three unless we consider parallel algorithms.

1. Sequential Time

An algorithm runs step-by-step in discrete time, thus defining a set of computational situations for each valid input.

2. Abstract State

Each computational situation can be defined using the first-order structure, and each algorithm is independent of its implementation. Thus, first-order structures in an ALG are invariant under isomorphism.

3. Bounded State

A wholly fixed and finite definition determines the transition from one state to another. In short, between each state and the next, only a fixed and finite number of terms of the current state can be considered.

In short, an algorithm is a solution method that works step by step, where each step can be clearly defined without reference to a specific computer, and also has a fixed limit for the amount of data that can be read/written in one step.

This broad definition can cover both practical algorithms and those that only work in theory. For example, Newton’s method and Gauss-Jordan elimination work infinitely, at least in principle. However, it is not possible to program an endless process on a computer.

In particular, Arithmetic can be considered as a fourth feature that can be used to verify that every computable function can be programmed in a Turing machine. In the first step, only computable transactions cannot be processed.

Algorithm Expression Methods

An algorithm can be done in many ways, including natural language, pseudocode, flowcharts, and programming languages.

Natural language descriptions tend to be vague and lengthy. However, using pseudocode and flowcharts removes many natural language ambiguities.

These expressions are more structured ways to represent ALGs. However, they remain independent of a particular programming language.

The description of an algorithm is usually made in high-level expression, form, and application.

In the high-level description, the problem is set up, a mathematical model is chosen, and the algorithm is verbally explained with pictures and details. If an element is greater than the maximum, its value is assigned to the maximum.

To find the maximum element, the value of the first element is assumed to be maximum. Each value is then compared with the value of the maximum number found so far.

In figural expression, pseudocode is used to describe the sequence of steps that find the solution.

In the implementation method, some objects that can perform the algorithm or commands expressed in a particular programming language are shown. It is also possible to include a theory that indicates that it is correct, the complexity analysis, or both.

Algorithm Diagrams

Flowchart

Flowcharts are graphic descriptions of ALGs. They use symbols associated with arrows to indicate the order of instructions and are governed by the ISO.

They are used to represent small ALGs because they take up a lot of space and are somewhat challenging to create.

Because of their ease of reading, they are used as an introduction to ALGs, a description of a language, and a description of processes to people outside of computing.

Structured Rectangular Diagrams

One of the challenges of flowcharts is that they provide the possibility to illustrate the flow of the solution to a problem graphically.

An erratic programmer misplacing the flow arrows can eventually lead to a more complex situation than the idea itself. In another case, it allows using graphical tools to represent the solution to a problem.

It is based on representing the entire algorithm in a rectangular frame. Unlike the previous technique, it basically uses three symbols corresponding to each of the basic structures of programming logic.

Pseudocode

Pseudocode is a method that looks like a programming language but has some natural language rules. It represents particularly complex instructions as it has many advantages over flowcharts. Also, it is not subject to any standard.

Pseudocode has a group of keywords and symbols that make up the vocabulary to represent the actions of this technique for computational ALGs.

To draw a flowchart using this technique, the following rules must be followed:

1. First Step

The word ALG is written, and the name of the ALG is written after space. Thus, a reference is made to the stated situation.

If we call the Pseudocode X, its purpose may not be so obvious. However, if we give the name Variable for the pseudocode, we can more easily say that its purpose is variable.

2. Second Step

The entire body of the ALG should be enclosed in the words Start and End, showing where the pseudocode begins and ends.

3. Third Step

After inserting the word begin, we need to state the state of the work to be done.

4. Fourth Step

In the last step, actions are written after the work to be done is declared.

Formal

Automata theory and the theory of iterative functions provide mathematical models that formalize the concept of ALGs. The most common models are the Turing machine, recorder, and μ – recursive functions.

These models are as precise as a machine language. They do not have colloquial expressions or ambiguity, but they are independent of any computer and any application.

Implementation

Many ALGs are designed to be implemented in a program. However, ALGs can also be applied in other environments, such as a neural network, an electrical circuit, or a mechanical and electrical device.

Some ALGs are even specially designed to be applied using a pencil and paper.

The traditional multiplication ALG, Euclid’s ALG, Eratosthenes’ sieve, and many ways to solve the square root are just a few examples.

Functional Algorithms

It is a diagram of an ALG that solves the Hamilton loop problem and can be thought of as a function that converts the data of a problem (input) into the data of a solution (output).

Also, the data itself can be represented as sequences of bits and generally as sequences of any symbol. Since each bitstream represents a natural number, ALGs are functions of natural numbers that can be calculated.

Each flowchart computes a function where each natural number is the encoding of a problem or a solution. For example, when they enter an endless loop, they may never end.

In such a case, it never returns any output value, and we can say that the function for that input value is undefined.

ALGs are, therefore, considered partial functions, meaning they do not have to be defined in all domains.

When algorithmic methods can calculate a function, the function is said to be computable, regardless of the amount of memory it occupies or the time it takes. Not all tasks between data strings can be calculated.

Analysis

As a measure of the efficiency of an ALG, the resources consumed by the system are examined. ALG analysis was developed to obtain values ​​that somehow show the evolution of time and memory expenditure as a function of the size of the input values.

The analysis and study of ALGs is a discipline of computer science, and in most cases, its work is entirely abstract without using any programming language or other applications.

Therefore, it shares the characteristics of mathematics disciplines in this sense. Thus, the analysis of ALGs focuses on the basic principles of the ALG, not on a specific application.

One way to construct an ALG is to write it in pseudocode or use a straightforward language such as Lexicon, whose code can be in the programmer’s language.

While some software developers limit the definition of an algorithm to procedures that must terminate at some point, others consider procedures that can be executed without stopping indefinitely, assuming the existence of some physical device that can run indefinitely.

In the second case, the successful completion of the ALG cannot be defined as its termination with satisfactory output.

However, success will be defined as a function of the output sequences delivered over a lifetime of running the ALG.

For example, a flowchart that verifies that there are multiple zeros in an infinite binary array must always be executed in order to return a valid value. If implemented correctly, the value returned by the system will be valid until it evaluates the next binary digit.

The output of this ALG is defined as the return of only positive values ​​if there are multiple zeros in the array. In any other case, it returns a mixture of positive and negative signals.

Algorithm Types & Classification

  • Greedy

Until a solution is found, the most promising elements are applied, and in most cases, the solution is not optimal.
Parallel

They allow a problem to be divided into sub-problems so that they can be run on multiple processors simultaneously.

  • Probabilistic

Some steps in this type of ALG are based on pseudo-random values.

  • Deterministic

The behavior of this method is linear, and there is only one successor and one precursor step in each step.

  • Non-Deterministic

The behavior of the ALG is tree-shaped, and each step can be branched into any number of steps immediately after it, and all branches are executed simultaneously.

  • Divide and Conquer

They divide the problem into separate subgroups, find a solution for each, and then combine them, thereby solving the entire problem.

  • Metaheuristics

Metaheuristics are based on the method of finding approximate non-optimal solutions to problems based on previous knowledge of the issues.

  • Dynamic Scheduling

It tries to solve problems by increasing spatial costs and decreasing calculation costs.

  • Branching and Dimensioning

It is based on finding a solution to the problem by finding the best solutions and by means of an implicit tree that is passed in a controlled manner.

  • Backtracking

The solution area of ​​the problem is based on the method of building a thoroughly studied tree that stores the cheapest solutions.

.

To draw a flowchart using this technique, the following rules must be followed:

1. First Step

The word ALG is written, and the name of the ALG is written after space. Thus, a reference is made to the stated situation.

If we call the Pseudocode X, its purpose may not be so obvious. However, if we give the name Variable for the pseudocode, we can more easily say that its purpose is variable.

2. Second Step

The entire body of the ALG should be enclosed in the words Start and End, showing where the pseudocode begins and ends.

3. Third Step

After inserting the word begin, we need to state the state of the work to be done.

4. Fourth Step

In the last step, actions are written after the work to be done is declared.

Formal

Automata theory and the theory of iterative functions provide mathematical models that formalize the concept of ALGs. The most common models are the Turing machine, recorder, and μ – recursive functions.

These models are as precise as a machine language. They do not have colloquial expressions or ambiguity, but they are independent of any computer and any application.

Implementation

Many ALGs are designed to be implemented in a program. However, ALGs can also be applied in other environments, such as a neural network, an electrical circuit, or a mechanical and electrical device.

Some ALGs are even specially designed to be applied using a pencil and paper.

The traditional multiplication ALG, Euclid’s ALG, Eratosthenes’ sieve, and many ways to solve the square root are just a few examples.

Functional Algorithms

It is a diagram of an ALG that solves the Hamilton loop problem and can be thought of as a function that converts the data of a problem (input) into the data of a solution (output).

Also, the data itself can be represented as sequences of bits and generally as sequences of any symbol. Since each bitstream represents a natural number, ALGs are functions of natural numbers that can be calculated.

Each flowchart computes a function where each natural number is the encoding of a problem or a solution. For example, when they enter an endless loop, they may never end.

In such a case, it never returns any output value, and we can say that the function for that input value is undefined.

ALGs are, therefore, considered partial functions, meaning they do not have to be defined in all domains.

When algorithmic methods can calculate a function, the function is said to be computable, regardless of the amount of memory it occupies or the time it takes. Not all tasks between data strings can be calculated.

Analysis

As a measure of the efficiency of an ALG, the resources consumed by the system are examined. ALG analysis was developed to obtain values ​​that somehow show the evolution of time and memory expenditure as a function of the size of the input values.

The analysis and study of ALGs is a discipline of computer science, and in most cases, its work is entirely abstract without using any programming language or other applications.

Therefore, it shares the characteristics of mathematics disciplines in this sense. Thus, the analysis of ALGs focuses on the basic principles of the ALG, not on a specific application.

One way to construct an ALG is to write it in pseudocode or use a straightforward language such as Lexicon, whose code can be in the programmer’s language.

While some software developers limit the definition of an algorithm to procedures that must terminate at some point, others consider procedures that can be executed without stopping indefinitely, assuming the existence of some physical device that can run indefinitely.

In the second case, the successful completion of the ALG cannot be defined as its termination with satisfactory output.

However, success will be defined as a function of the output sequences delivered over a lifetime of running the ALG.

For example, a flowchart that verifies that there are multiple zeros in an infinite binary array must always be executed in order to return a valid value. If implemented correctly, the value returned by the system will be valid until it evaluates the next binary digit.

The output of this algorithm is defined as the return of only positive values ​​if there are multiple zeros in the array. In any other case, it returns a mixture of positive and negative signals.

Algorithm Types & Classification

  • Greedy

Until a solution is found, the most promising elements are applied, and in most cases, the solution is not optimal.
Parallel

They allow a problem to be divided into sub-problems so that they can be run on multiple processors simultaneously.

  • Probabilistic

Some steps in this type of algorithm are based on pseudo-random values.

  • Deterministic

The behavior of this method is linear, and there is only one successor and one precursor step in each step.

  • Non-Deterministic

The bealgorithm’s havior of tree-shaped, and each step can be branched into any number of steps immediately after it, and all branches are executed simultaneously.

  • Divide and Conquer

They divide the problem into separate subgroups, find a solution for each, and then combine them, thereby solving the entire problem.

  • Metaheuristics

Metaheuristics are based on the method of finding approximate non-optimal solutions to problems based on previous knowledge of the issues.

  • Dynamic Scheduling

It tries to solve problems by increasing spatial costs and decreasing calculation costs.

  • Branching and Dimensioning

It is based on finding a solution to the problem by finding the best solutions and by means of an implicit tree that is passed in a controlled manner.

  • Backtracking

The solution area of ​​the problem is based on the method of building a thoroughly studied tree that stores the cheapest solutions.

Add a Comment

Your email address will not be published. Required fields are marked *