How do you differentiate between an algorithm and a method? Why dont we call Newton's Method or Ford-Faulkerson method Algorithms? What are a properties of a good algorithm and what qualifies a method as an algorithm?
Regarding the Ford-Faulkerson Method, CLRS calls it method rather than algorithm because "it encompasses several implementation with different running time"[pp 651. 2nd editon]
Algorithms terminate in a finite number of steps.
A procedure that has all of the characteristics of an algorithm except that it possible lacks finiteness may be called a computational method. Euclid originally presented not only an algorithm for the greatest common divisor of numbers, but also a very similar geometrical construction for the "greatest common measure" of the lengths of two line segments; this is a computational method that does not terminate if the given lengths are incommensurable. -- D.Knuth, TAOCP vol 1, Basic Concepts: Algorithms
The Newton Raphson method is not guaranteed to converge, not does it detect convergence failure. If you wrap the method up with convergence detection and termination at a finite epsilon or after a finite number of steps, you get an algorithm.
There is no technical difference between the term "method" as in "Newton's method" and "algorithm."
EDIT: On reflection, perhaps Pete is correct that algorithms terminate and methods may not (who am I to argue with Knuth?) However, I don't think that's a distinction that most people will make based only on your use of one word or the other.
In my opinion, a method is a more general concept than algorithm and can be more or less anything, e.g. writing data to a file. Just about anything that should happen due to an event or to some logical expression. Also, the meaning of the words "method" and "algorithm" can vary depending on in what context they are used. They might be used to describe the same thing.
In general programming speak, algorithms are the steps by which a task is accomplished. According to Wikipedia,
an algorithm is a finite sequence of instructions, an explicit, step-by-step procedure for solving a problem, often used for calculation and data processing. It is formally a type of effective method in which a list of well-defined instructions for completing a task, will when given an initial state, proceed through a well-defined series of successive states, eventually terminating in an end-state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as probabilistic algorithms, incorporate randomness. <
In computer science, a method or function is part of the Object-Oriented philosophy to programming where programs are made out of classes that contains methods/functions to perform specific tasks. Once again, quoting Wikipedia
In object-oriented programming, a method is a subroutine that is exclusively associated either with a class (called class methods or static methods) or with an object (called instance methods). Like a procedure in procedural programming languages, a method usually consists of a sequence of statements to perform an action, a set of input parameters to customize those actions, and possibly an output value (called the return value) of some kind. Methods can provide a mechanism for accessing (for both reading and writing) the encapsulated data stored in an object or a class. <
In short, the algorithm are the steps by which we do something such as turning a light bulb on:
1) Walk to switch 2) Flip Switch 3) Electrons Flow 4) Light generated
Methods are where we actually code actions inside a class.
Well, for the etymology-lovers
http://www.etymonline.com/index.php?search=algorithm+method&searchmode=or
Algorithm is just like a formula to solve any particular problem step by step,with no ambiguity to any step, and must have some ending point. methodology is more general form of any solution. it provided a way how to solve any problem but in algorithm the way is more precisely formulated towards solution.
Method is analogous to a strategy, algorithm is analogous to the tactics. An example: in war, you develop a strategy (method) to take over a country: take ports first, advance west on land, then surround capital, etc. This strategy is divided in several tactical stages (algorithms): first, one that tells the soldiers step by step exactly how they are going to take the ports; then, one that tell the soldiers how they must advances west; then, one with the exact steps for the soldiers to surround the city, etc.
I think it is just because the origin domain of algorithm. If the inventor is in computer science background, he may prefer called algorithm. In the domain of math and other sciences, they may prefer called method.
In the context you state (Newton's method, etc.) there is no essential difference between an algorithm and a method. Both are sets step-by-step instructions for solving a problem. In the Wikipedia article on Newton's Method, it states "The algorithm is first in the class of Householder's methods, succeeded by Halley's method". The boundary is blurry at best.
In computer science an algorithm still is a step-by-step manner towards solving a problem - an implementation-agnostic set of steps. A method commonly refers to a chunk of code associated with a class or object that does some task - it can implement many algorithms potentially.
A procedure can go on forever. Where as an Algorithm, will eventually terminate and will have each step precisely defined.
Alan Turing was the first to introduce the word "algorithm" in mathematical literature. According to Gödel,
Turing’s work gives an analysis of the concept of ‘mechanical procedure’ (alias ‘algorithm’ or ‘computation procedure’ or ‘finite combinatorial procedure’). This concept is shown to be equivalent with that of a ‘Turing machine’
In other words an algorithm is a computable function together with a method of computation, that is correct and finite. Note that a well-defined function has certain value for every possible argument. On the other hand method is a strictly formalized way of doing something. So every algorithm is a method, but not vice versa. Methods not being algorithms may:
- Be (potentially) not finite.
- Give (potentially) incorrect answer.
- Solve problems with multiple correct answers.
- Solve problems with no definitely correct answer (including real-life image recognition).
- Solve undecidable problems.
On the other hand classic algorithm has three main properties:
- Provable finiteness.
- Provable correctness.
- Two different algorithms for the same problem give the same answer.
Nowadays people try to use word algorithm for any well-defined action, i. e., instead of word method. But more or less reasonable direction to extend meaning of word algorithm keep the key property of provability of correctness (with pen and paper) and ability to bound running time. Meaning of correctness may also be extended to provide some property of the answer, not one-to-one equality only. E. g., approximation scheme gives solution within some known distance from the optimal one.
Further extension of correctness meaning is about giving correct answer with known probability (which still can be lower-bounded with pen and paper by a constant or a function of input size). At the same time we can speak about expected running time and being finite almost always (with probability 1). These two extensions together bring us to probabilistic algorithms.
So if we return to the question about Newton's method and Ford—Fulkerson method, then the answer is the following: these methods are not algorithms in Turing's definition. Newton's method both is not finite and gives one of multiple root, while Ford—Fulkerson method gives one of multiple flows. But as soon as we extend meaning of correctness allowing multiple correct solutions, Ford—Fulkerson method becomes an algorithm. If we at the same time accept as correct any answer close enough to a root, then Newton's method becomes an algorithm for computing an approximation of root of a function with continuous second derivative.
Regarding the Ford-Faulkerson Method, CLRS calls it method rather than algorithm because "it encompasses several implementation with different running time"[pp 651. 2nd editon]
© 2022 - 2024 — McMap. All rights reserved.