Algorithm
of two numbers.|alt=In a loop, subtract the larger number against the smaller number. Halt the loop when the subtraction will make a number negative. Assess two numbers, whether one of them is equal to zero or not. If yes, take the other number as the greatest common divisor. If no, put the two numbers in the subtraction loop again. In mathematics and computer science, an algorithm ( ) is any well-defined set of instructions that when followed terminates after a finite number of steps that comprise a solution to a given computational problem. Advanced algorithms may utilize loops and involve many conditionals that decide the next step based on the inputs provided, resulting in long sequences of steps before halting, but all algorithms terminate by definition. In contrast to algorithms, heuristics might be applied to problems for which it is not possible for an algorithmic solution to exist, e.g., because the problem is undecidable or there is otherwise no way to define the correct...
of two numbers.|alt=In a loop, subtract the larger number against the smaller number. Halt the loop when the subtraction will make a number negative. Assess two numbers, whether one of them is equal to zero or not. If yes, take the other number as the greatest common divisor. If no, put the two numbers in the subtraction loop again. In mathematics and computer science, an algorithm ( ) is any well-defined set of instructions that when followed terminates after a finite number of steps that comprise a solution to a given computational problem. Advanced algorithms may utilize loops and involve many conditionals that decide the next step based on the inputs provided, resulting in long sequences of steps before halting, but all algorithms terminate by definition. In contrast to algorithms, heuristics might be applied to problems for which it is not possible for an algorithmic solution to exist, e.g., because the problem is undecidable or there is otherwise no way to define the correct or optimal result. For example, although social media recommender systems are erroneously called "algorithms" in popular media, they are accurately classified as heuristics, because there is no objective criteria by which a recommendation produced by such a system can be judged as "correct". As an effective method, an algorithm can be expressed within both a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and input, a computation occurs at each step, eventually producing output and terminating. Randomized algorithms incorporate random inputs which can be used to simulate non-deterministic output even though the transitions between states are deterministic. ==Representations== Algorithms can be expressed in many kinds of notation, including natural languages, pseudocode, flowcharts, drakon-charts, programming languages or control tables. Natural language expressions of algorithms tend to be verbose and ambiguous and are rarely used for complex or technical algorithms. Pseudocode, flowcharts, drakon-charts, and control tables are structured expressions of algorithms that avoid common ambiguities of natural language. Programming languages are primarily for expressing algorithms in a computer-executable form but are also used to define or document algorithms. ===Formal versus empirical=== The analysis, and study of algorithms is a discipline of computer science. Algorithms are often studied abstractly, without referencing a specific programming language or implementation. Like other mathematical disciplines, it focuses on the algorithm's properties, not implementation. Pseudocode is typical for analysis as it is a simple and general representation. Most algorithms are implemented on particular hardware/software platforms and their algorithmic efficiency is tested using real code. The efficiency of a particular algorithm may be insignificant for many "one-off" problems but it can be critical for algorithms designed for fast, interactive, commercial, or long-life scientific usage. Increasing the input size often exposes inefficient algorithms that are otherwise benign. Empirical testing is useful for uncovering unexpected interactions that affect performance. Benchmarks may be used to compare before/after potential improvements to an algorithm after program optimization. Empirical tests cannot fully replace formal analysis, and are difficult to perform fairly. if L.size = 0 return null largest ← L[0] for each item in L, do if item > largest, then largest ← item return largest Algorithm = Logic + Control Algorithm aversion Algorithm engineering Algorithm characterizations Algorithmic bias Algorithmic composition Algorithmic entities Algorithmic synthesis Algorithmic technique Algorithmic topology Computational mathematics Garbage in, garbage out Introduction to Algorithms (textbook) Government by algorithm List of algorithms List of algorithm books List of algorithm general topics Medium is the message Outline of algorithms Regulation of algorithms Theory of computation Computability theory Computational complexity theory Yuri Gurevich, Sequential Abstract State Machines Capture Sequential Algorithms, ACM Transactions on Computational Logic, Vol 1, no 1 (July 2000), pp. 77–111. Includes bibliography of 33 sources. , 3rd edition 1976[?], (pbk.) , . Cf. Chapter "The Spirit of Truth" for a history leading to, and a discussion of, his proof. Presented to the American Mathematical Society, September 1935. Reprinted in The Undecidable, p. 237ff. Kleene's definition of "general recursion" (known now as mu-recursion) was used by Church in his 1935 paper An Unsolvable Problem of Elementary Number Theory that proved the "decision problem" to be "undecidable" (i.e., a negative result). Reprinted in The Undecidable, p. 255ff. Kleene refined his definition of "general recursion" and proceeded in his chapter "12. Algorithmic theories" to posit "Thesis I" (p. 274); he would later repeat this thesis (in Kleene 1952:300) and name it "Church's Thesis"(Kleene 1952:317) (i.e., the Church thesis). Kosovsky, N.K. Elements of Mathematical Logic and its Application to the theory of Subrecursive Algorithms, LSU Publ., Leningrad, 1981 A.A. Markov (1954) Theory of algorithms. [Translated by Jacques J. Schorr-Kon and PST staff] Imprint Moscow, Academy of Sciences of the USSR, 1954 [i.e., Jerusalem, Israel Program for Scientific Translations, 1961; available from the Office of Technical Services, U.S. Dept. of Commerce, Washington] Description 444 p. 28 cm. Added t.p. in Russian Translation of Works of the Mathematical Institute, Academy of Sciences of the USSR, v. 42. Original title: Teoriya algerifmov. [QA248.M2943 Dartmouth College library. U.S. Dept. of Commerce, Office of Technical Services, number OTS .] Minsky expands his "...idea of an algorithm – an effective procedure..." in chapter 5.1 Computability, Effective Procedures and Algorithms. Infinite machines. Reprinted in The Undecidable, pp. 289ff. Post defines a simple algorithmic-like process of a man writing marks or erasing marks and going from box to box and eventually halting, as he follows a list of simple instructions. This is cited by Kleene as one source of his "Thesis I", the so-called Church–Turing thesis. Reprinted in The Undecidable, p. 223ff. Herein is Rosser's famous definition of "effective method": "...a method each step of which is precisely predetermined and which is certain to produce the answer in a finite number of steps... a machine which will then solve any problem of the set with no human intervention beyond inserting the question and (later) reading the answer" (p. 225–226, The Undecidable) Cf. in particular the first chapter titled: Algorithms, Turing Machines, and Programs. His succinct informal definition: "...any sequence of instructions that can be obeyed by a robot, is called an algorithm" (p. 4). . Corrections, ibid, vol. 43(1937) pp. 544–546. Reprinted in The Undecidable, p. 116ff. Turing's famous paper completed as a Master's dissertation while at King's College Cambridge UK. Reprinted in The Undecidable, pp. 155ff. Turing's paper that defined "the oracle" was his PhD thesis while at Princeton. United States Patent and Trademark Office (2006), 2106.02 **>Mathematical Algorithms: 2100 Patentability, Manual of Patent Examining Procedure (MPEP). Latest revision August 2006 Zaslavsky, C. (1970). Mathematics of the Yoruba People and of Their Neighbors in Southern Nigeria. The Two-Year College Mathematics Journal, 1(2), 76–99. https://doi.org/10.2307/3027363 NIST Releases First 3 Finalized Post-Quantum Encryption Standards. https://www.nist.gov/news-events/news/2024/08/nist-releases-first-3-finalized-post-quantum-encryption-standards ==Further reading== Jon Kleinberg, Éva Tardos(2006): Algorithm Design, Pearson/Addison-Wesley, ISBN 978-0-32129535-4 Knuth, Donald E. (2000). Selected Papers on Analysis of Algorithms . Stanford, California: Center for the Study of Language and Information. Knuth, Donald E. (2010). Selected Papers on Design of Algorithms . Stanford, California: Center for the Study of Language and Information. ==External links== Dictionary of Algorithms and Data Structures – National Institute of Standards and Technology Algorithm repositories The Stony Brook Algorithm Repository – State University of New York at Stony Brook Collected Algorithms of the ACM – Associations for Computing Machinery The Stanford GraphBase – Stanford University
References
- ^ "A procedure which has all the characteristics of an algorithm except that it possibly lacks finiteness may be called a 'computational method ' " (Knuth 1971:5). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "algorism" . Oxford English Dictionary . Retrieved May 18, 2025 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Chaucer, Geoffrey. "The Miller's Tale" . Line 3210. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Skeat, Walter William (1914). "agrim, agrum" . In Mayhew, Anthony Lawson (ed.). A Glossary of Tudor and Stuart Words: Especially from the Dramatists . Clarendon Press. pp. 5– 6. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Grabiner, Judith V. (December 2013). "The role of mathematics in liberal arts education". In Matthews, Michael R. (ed.). International Handbook of Research in History, Philosophy and Science Teaching . Springer. pp. 793– 836. doi : 10.1007/978-94-007-7654-8_25 . ISBN 978-94-007-7654-8 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "algorithm" . Oxford English Dictionary . Retrieved May 18, 2025 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Simanowski, Roberto (2018). The Death Algorithm and Other Digital Dilemmas . Untimely Meditations. Vol. 14. Translated by Chase, Jefferson. Cambridge, Massachusetts: MIT Press. p. 147. ISBN 978-0-262-53637-0 . Archived from the original on December 22, 2019 . Retrieved May 27, 2019 . [...] the next level of abstraction of central bureaucracy: globally operating algorithms. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Dietrich, Eric (2001). "Algorithm". In Wilson, Robert Andrew; Keil, Frank C. (eds.). The MIT Encyclopedia of the Cognitive Sciences . MIT Cognet library. Cambridge, Massachusetts: MIT Press. p. 11. ISBN 978-0-262-73144-7 . Retrieved 22 July 2020 . An algorithm is a recipe, method, or technique for doing something. {{ cite book }} : Check date values in: |year= / |publication-date= mismatch ( help ) Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Stone requires that "it must terminate in a finite number of steps" (Stone 1973:7–8). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Boolos and Jeffrey 1974, 1999:19 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Hayashi, T. (2023, January 1). Brahmagupta . Encyclopedia Britannica. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Zaslavsky, Claudia (1970). "Mathematics of the Yoruba People and of Their Neighbors in Southern Nigeria". The Two-Year College Mathematics Journal . 1 (2): 76– 99. doi : 10.2307/3027363 . ISSN 0049-4925 . JSTOR 3027363 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Chabert, Jean-Luc, ed. (1999). A History of Algorithms . doi : 10.1007/978-3-642-18192-4 . ISBN 978-3-540-63369-3 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Knuth, Donald E. (1972). "Ancient Babylonian Algorithms" (PDF) . Commun. ACM . 15 (7): 671– 677. doi : 10.1145/361454.361514 . ISSN 0001-0782 . S2CID 7829945 . Archived from the original (PDF) on December 24, 2012. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Aaboe, Asger (2001). Episodes from the Early History of Astronomy . New York: Springer. pp. 40– 62. ISBN 978-0-387-95136-2 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Ast, Courtney. "Eratosthenes" . Wichita State University: Department of Mathematics and Statistics. Archived from the original on February 27, 2015 . Retrieved February 27, 2015 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Knuth, Donald E. (1996). Selected Papers on Computer Science . CSLI Publications. pp. 1– 2. Al-Khwarizmi's work was the first to provide a systematic, rule-based approach to solving equations, which is why the word 'algorithm' was coined from his name to describe this methodical process. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Bolter 1984:24 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Bolter 1984:26 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Bolter 1984:33–34, 204–206. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Bell and Newell diagram 1971:39, cf. Davis 2000 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Melina Hill, Valley News Correspondent, A Tinkerer Gets a Place in History , Valley News West Lebanon NH, Thursday, March 31, 1983, p. 13. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Davis 2000:14 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Kleene 1943 in Davis 1965:274 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Rosser 1939 in Davis 1965:225 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Gurevich, Yuri (2000). "Sequential abstract-state machines capture sequential algorithms". ACM Transactions on Computational Logic . 1 (1): 77– 111. doi : 10.1145/343369.343384 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Moschovakis, Yiannis N.; Paschalis, Vasilis (2008). "Elementary Algorithms and Their Implementations". New Computational Paradigms . Springer. pp. 87– 118. doi : 10.1007/978-0-387-68546-5_5 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Gillian Conahan (January 2013). "Better Math Makes Faster Data Networks" . discovermagazine.com. Archived from the original on May 13, 2014 . Retrieved May 13, 2014 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "Best Case" . Dictionary of Algorithms and Data Structures . National Institute of Standards and Technology (NIST). National Institute of Standards and Technology . Retrieved May 29, 2025 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "worst case" . Dictionary of Algorithms and Data Structures . National Institute of Standards and Technology (NIST). National Institute of Standards and Technology (NIST) . Retrieved May 29, 2025 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Goodrich, Michael T. ; Tamassia, Roberto (2002). Algorithm Design: Foundations, Analysis, and Internet Examples . John Wiley & Sons, Inc. ISBN 978-0-471-38365-9 . Archived from the original on April 28, 2015 . Retrieved June 14, 2018 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "Big-O notation (article) | Algorithms" . Khan Academy . Retrieved June 3, 2024 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Tausworthe 1977:101 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "an algorithm is a procedure for computing a function (concerning some chosen notation for integers) ... this limitation (to numerical functions) results in no loss of generality", (Rogers 1977:1). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Tausworthe 1977:142 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Knuth 1973 section 1.2.1, expanded by Tausworthe 1977 at pages 100ff and Chapter 9.1 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "The Experts: Does the Patent System Encourage Innovation?" . The Wall Street Journal . May 16, 2013. ISSN 0099-9660 . Retrieved March 29, 2017 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Kellerer, Hans; Pferschy, Ulrich; Pisinger, David (2004). Knapsack Problems | Hans Kellerer | Springer . Springer. doi : 10.1007/978-3-540-24777-7 . ISBN 978-3-540-40286-2 . S2CID 28836720 . Archived from the original on October 18, 2017 . Retrieved September 19, 2017 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Goodrich, Michael T.; Tamassia, Roberto (2001). "5.2 Divide and Conquer". Algorithm Design: Foundations, Analysis, and Internet Examples . John Wiley & Sons. p. 263. ISBN 978-0-471-38365-9 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ For instance, the volume of a convex polytope (described using a membership oracle) can be approximated to high accuracy by a randomized polynomial time algorithm, but not by a deterministic one: see Dyer, Martin; Frieze, Alan; Kannan, Ravi (January 1991). "A Random Polynomial-time Algorithm for Approximating the Volume of Convex Bodies". J. ACM . 38 (1): 1– 17. doi : 10.1145/102782.102783 . S2CID 13268711 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ George B. Dantzig and Mukund N. Thapa. 2003. Linear Programming 2: Theory and Extensions . Springer-Verlag. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "An algorithm has one or more outputs, i.e., quantities which have a specified relation to the inputs" (Knuth 1973:5). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Whether or not a process with random interior processes (not including the input) is an algorithm is debatable. Rogers opines that: "a computation is carried out in a discrete stepwise fashion, without the use of continuous methods or analog devices ... carried forward deterministically, without resort to random methods or devices, e.g., dice" (Rogers 1987:2). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "Definition of ALGORITHM" . Merriam-Webster Online Dictionary . Archived from the original on February 14, 2020 . Retrieved November 14, 2019 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Blair, Ann, Duguid, Paul, Goeing, Anja-Silvia and Grafton, Anthony. Information: A Historical Companion, Princeton: Princeton University Press, 2021. p. 247 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b David A. Grossman, Ophir Frieder, Information Retrieval: Algorithms and Heuristics , 2nd edition, 2004, ISBN 1402030045 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "Any classical mathematical algorithm, for example, can be described in a finite number of English words" (Rogers 1987:2). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Well defined concerning the agent that executes the algorithm: "There is a computing agent, usually human, which can react to the instructions and carry out the computations" (Rogers 1987:2). Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b c d Sipser 2006:157 Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b Sriram, M. S. (2005). "Algorithms in Indian Mathematics" . In Emch, Gerard G.; Sridharan, R.; Srinivas, M. D. (eds.). Contributions to the History of Indian Mathematics . Springer. p. 153. ISBN 978-93-86279-25-5 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b c Cooke, Roger L. (2005). The History of Mathematics: A Brief Course . John Wiley & Sons. ISBN 978-1-118-46029-0 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b Dooley, John F. (2013). A Brief History of Cryptology and Cryptographic Algorithms . Springer Science & Business Media. pp. 12– 3. ISBN 978-3-319-01628-3 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Goodrich & Tamassia (2001) , p. 245, 4.7.1 Prune-and-search. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Stone (1971) , p. 8. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Haitham Hassanieh, Piotr Indyk , Dina Katabi, and Eric Price, " ACM-SIAM Symposium On Discrete Algorithms (SODA) Archived July 4, 2013, at the Wayback Machine , Kyoto, January 2012. See also the sFFT Web Page Archived February 21, 2012, at the Wayback Machine . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Kriegel, Hans-Peter ; Schubert, Erich; Zimek, Arthur (2016). "The (black) art of run-time evaluation: Are we comparing algorithms or implementations?". Knowledge and Information Systems . 52 (2): 341– 378. doi : 10.1007/s10115-016-1004-2 . ISSN 0219-1377 . S2CID 40772241 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ a b c d Chabert, Jean-Luc (2012). A History of Algorithms: From the Pebble to the Microchip . Springer Science & Business Media. pp. 7– 8. ISBN 978-3-642-18192-4 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ "AlphaDev discovers faster sorting algorithms" . Google DeepMind . June 7, 2023 . Retrieved April 29, 2026 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Mankowitz, Daniel J.; Michalski, Andrea; Zhernov, Anton; Gelmi, Marco; Selvi, Marco; et al. (June 2023). "Faster sorting algorithms discovered using deep reinforcement learning". Nature . 618 (7964): 257– 263. doi : 10.1038/s41586-023-06004-9 . PMID 37286649 . Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
- ^ Novikov, Alexander; Vu, Ngân; Eisenberger, Marvin; Dupont, Emilien; Huang, Po-Sen; et al. (2025). "AlphaEvolve: A coding agent for scientific and algorithmic discovery". arXiv : 2506.13131 [ cs.AI ]. Wikipedia revision 1376037819, retrieved 2026-11-21 · 1795215600.0
Cite this
"Algorithm". 1790003913. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1376037819