M
M
Michael2021-04-01 13:37:24
Algorithms
Michael, 2021-04-01 13:37:24

Can any piece of program code be considered an algorithm?

Hello!
I understand that the question is essentially fundamental, but it would be interesting to understand it in a little more detail.

The algorithm has a definition and properties:

An algorithm is a system of precise and understandable instructions about the content and sequence of performing a finite number of actions necessary to solve any problem of a given type.

Examples: rules for addition, multiplication, solving algebraic equations, etc.

Properties of the algorithm:

1. Universality (mass character) - the applicability of the algorithm to various sets of initial data.

2.Discreteness - the process of solving the problem according to the algorithm is divided into separate actions.

3. Finiteness - each of the actions and the entire algorithm as a whole must be completed.

4. Efficiency - upon completion of the algorithm, the final result is necessarily obtained.

5.Practicability (efficiency) - the result of the algorithm is achieved in a finite number of steps.

6. Determinacy (definiteness) - the algorithm should not contain prescriptions, the meaning of which can be perceived ambiguously. Those. the same prescription, when executed, must produce the same result.

7. Sequence - the order of execution of commands should be clear to the performer and should not allow ambiguity.


Algorithms can also be classified and they come in different types.

I often heard that an algorithm is just a sequence of actions, so I want to clarify:
1. Is it possible to write code that is not an algorithm?
2. Is an instruction with a single action an algorithm?
3. Is layout an algorithm and can it be considered code at all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2021-04-01
@mikhailushka

1. Is it possible to write code that is not an algorithm?

Yes. For example, this is how declarative languages ​​work, such as HTML, SQL, CSS.
2. Is an instruction with a single action an algorithm?

Yes.
3. Is layout an algorithm and can it be considered code at all?

Code - yes. Algorithm - no, since the layout does not describe the steps to achieve the result.

V
VitalyChaikin, 2021-04-01
@VitalyChaikin

1. Is it possible to write code that is not an algorithm?
Yes, if it violates one of the seven principles
2. Is an instruction with a single action an algorithm?
I think so
3. Is layout an algorithm and can it be considered code at all?
I think so, because does not violate principles 1 - 7

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question