The best consideration to make is that your example is a computational method, but not an algorithm. I will argue why this statement follows.
Like:
- Almost all major articles that contributed to the definition of the word algorithm are in English.
- And most computer books in Portuguese that use the word algorithm are based on references in English.
Let’s consider that the meaning of the word algorithm is the same as the equivalent in English Algorithm. So we can look for the definition of reliable and weighty sources in math and computing media.
Definition by Cambrige Dictionary:
A set of Mathematical Instructions that must be Followed in a Fixed order, and that, especially if Given to a computer, will help to calculate an Answer to a Mathematical problem.
Set of mathematical instructions that must be followed in a fixed order, and which, especially if given to a computer, will help calculate an answer to a mathematical problem.
Definition by the Oxford Dictionary:
Math. and Computing. A Procedure or set of Rules used in calculation and problem-solving. A precisely defined set of Mathematical or Logical Operations for the performance of a particular task.
Mathematics. and Computation. A procedure or set of rules used in the calculation and resolution of problems. A well-defined set of mathematical or logical operations for performing a given task.
Definition in Wolfram Mathworld:
An Algorithm is a specific set of Instructions for Carrying out a Procedure or solving a problem, usually with the requirement that the Procedure terminate at some point.
An algorithm is a specific set of instructions for performing a procedure or to solve a problem, usually with the requirement that the procedure ends at some point.
None of the three definitions explicitly rigorously states that an algorithm must terminate.
The classical definition of an algorithm is that of a sequential procedure ending at some point. However, new types of algorithms have emerged, such as parallel, interactive, distributed, analog, and quantum algorithms, which do not fit the classical definition. Thus, the concept of algorithm is still in the process of development and is not strictly defined.
But in practice, hardly a program that does not end will be said as an algorithm. An algorithm must solve a problem and therefore usually return a value that represents the solution. If at some point the solution has already been calculated, why should the algorithm continue? And if the solution is never calculated, the algorithm has no practical sense. The concept of an algorithm that does not end is more for theoretical than practical questions.
Therefore ouvir_ligações_porta_8080
is an algorithm because it solves a problem.
Already enquanto(VERDADE)
is a computational method that calls an algorithm several times, but it never gives a final answer to its problem, so it would be better not to call it an algorithm.
You can put a more complete quote?
– Maniero
I’ll do better, I’ll expand on the issue and take the reference to the book, which you think @bigown?
– Cold
I don’t know, this is a case that seems to me to be just a matter of interpretation. What’s not wrong with that.
– Maniero
@Cold Would that be the quote? Finiteness: An Algorithm must Always terminate after a Finite number of Steps. Algorithm e satisfies this condition, because after step E1 the value of r is Less than n; so if r != 0, the value of n decreaes the next time step E1 is encountered. A decreasing Sequence of Positive intergers must eventually terminate, so step E1 is executed only a Finite number of times for any Given original values of n. Note, However, that the number of Steps can become arbitrarily large; Certain Huge Choices of m and n will cause step E1 to be executed more than milions times.
– Randrade
@Randrade, it is no longer necessary. And the book in some way answers this question, but always wanted to hear other opinions.
– Cold
Todo algorítimo deve sempre terminar após um número finito de passos?
the answer is no to real-time system where certain functions tend to infinity, keep a door in Listen, keep a microphone capturing audio, freeze a frame infinitely (pause your blue ray) ... the subject is disturbing because nothing in life is infinite huahuahua, it is assumed that at some point its function will stop.– ederwander
@bigown Randrade’s quote can be seen and evaluated if in fact it is a question of interpretation :D
– Cold
In the quoted algorithm it is common for TRUTH to be a variable and this process tends to be finite as long as TRUTH is true. At some other time, another process may notify the precesso that Esculta links on port 8080 setting the value of TRUTH as false, causing the next iteration of TRUTH to have false value and not distorting more links on port 8080.
– wryel
@wryel, it is not necessarily a variable. Consider a pure true.
– Cold