甲状腺是什么科| 什么是接触性皮炎| p2大于a2什么意思| 什么而什么见| 身体发烧是什么原因| 奉子成婚是什么意思| 82年属什么的| 仙鹤代表什么生肖| 孕妇吃梨有什么好处| 速写男装属于什么档次| 什么奶粉好吸收好消化| 快照是什么意思| 黑色屎是什么原因| 铁锈是什么颜色的| 身上长红疙瘩很痒是什么原因| 女人吃鹅蛋有什么好处| 宫颈分离是什么意思| 鬼冢虎什么档次| gb10769是什么标准| 吃什么东西可以养胃| 动脉圆锥是什么意思| 柿子是什么颜色| 褙子是什么| 大便不成形是什么原因造成的| 孙悟空的原名叫什么| 儿童乘坐高铁需要什么证件| 技校算什么学历| 权志龙为什么叫gd| 梅雨季节是什么时候| 生米煮成熟饭是什么意思| 光敏树脂是什么材料| 菊花有什么功效| 什么是圣人| 下巴老是长痘痘是什么原因| 一马平川是什么意思| 北京市副市长什么级别| 男人手大代表什么| 喝豆浆有什么好处| 64年属什么生肖| 口腔溃疡不能吃什么| 肠胃胀气是什么原因| 老年人喝什么蛋白粉好| 考研都考什么| 脂血是什么意思| 25岁今年属什么生肖| 十月23日是什么星座| j是什么| 红茶什么季节喝最好| 姿态万千的意思是什么| 糖类抗原125是什么意思| 网黄什么意思| 生化是什么意思| 什么是微创手术| 贝母和川贝有什么区别| 猫瘟吃什么药| 关帝是什么神| 工装裤配什么鞋| 身份证后四位代表什么| 女人脚心发热吃什么药| 火影忍者大结局是什么| 什么是气胸有什么症状| 对峙什么意思| 一念之间什么意思| 鼻子旁边有痣代表什么| 早上起床牙龈出血是什么原因| 小孩晚上睡觉流口水是什么原因| 稀奶油是什么奶油| 绿幽灵五行属什么| 肺寒咳嗽吃什么药| 吃大枣有什么好处| 人性的弱点是什么| 奇亚籽是什么| 鬼怕什么东西| 做好自己是什么意思| 为什么家里会有蚂蚁| 1992年属什么生肖年| 什么是边界感| slogan是什么意思啊| fredperry是什么牌子| 嗓子疼看什么科室| 属虎的和什么属相最配| 什么人群不适合吃阿胶糕| 为什么女人阴唇会变黑| 西安有什么美食| 初中毕业可以考什么证| 大便带血是什么原因| 至多是什么意思| 波霸是什么| 宝付支付是什么| pa是什么元素| 三鹿奶粉现在叫什么| 减肥能吃什么水果| 肌酸是什么| 什么的感受| 为什么一生气就胃疼| 口腔经常溃疡是什么原因| 为什么排卵期会出血| chase是什么意思| 什么是偏爱| 什么食物消炎效果好| 被和谐了是什么意思| 腺病毒阳性是什么意思| 女人吃当归有什么好处| 为什么今年有两个六月| 频繁做梦是什么原因| 水泡型脚气用什么药| 发烧不退烧是什么原因| 7月份可以种什么菜| 天下之奇是什么生肖| 肚脐周围痛是什么原因| 痔疮吃什么药| 小三阳和大三阳有什么区别| 农历五月二十四是什么日子| 嗓子疼咽口水都疼吃什么药| 微喇裤配什么鞋子好看| 中国国酒是什么酒| 左耳疼痛什么原因引起| 尿隐血挂什么科| 貉是什么动物| 11度穿什么衣服| 什么颜色加什么颜色等于什么颜色| 廉租房和公租房有什么区别| 为什么会内分泌失调| 小孩子注意力不集中看什么科| 乳清是什么| 养流浪猫需要注意什么| 经血发黑什么原因| 佩字五行属什么| 压马路是什么意思| 咖啡喝多了有什么危害| 吃饭容易出汗是什么原因| 外痔用什么药| 发烧吃什么药退烧快| 弹力棉是什么面料| 湿气重吃什么调理| 病毒感冒吃什么消炎药| 共情是什么意思| 阴道炎是什么症状| 脑供血不足吃什么中成药| 囊性无回声是什么意思| 利多卡因是什么| qt什么意思| 电轴左偏什么意思| 11月16号是什么星座| 89年是什么命| 茼蒿和什么相克| bosco是什么意思| 紧急避孕药什么时候吃| 三下乡是什么意思| 外阴病变有什么症状| 寒风吹起细雨迷离是什么歌| 洛五行属性是什么| 备孕需要做些什么准备| 三元及第是什么意思| 早上口干口苦是什么原因| 前白蛋白偏低是什么意思| 泡芙是什么| 间歇是什么意思| 肚子大了是什么原因造成的| 什么是肺结节| 真菌孢子阳性什么意思| 级配是什么意思| 女人什么时候容易怀孕| 嬴政和芈月是什么关系| 飞龙在天是什么生肖| 眼压高有什么症状| 拔牙吃什么消炎药| 什么降肌酐| 背疼什么原因| bb霜是什么| 坤造是什么意思| led什么意思| 立克次体病是什么意思| 两面性是什么意思| 缺钾吃什么补得最快| cpp是什么意思| 生理期提前是什么原因| VH是什么品牌| 吃什么帮助消化通便| 电压高是什么原因造成| 眼睛有红血丝是什么原因| 阑尾炎手术后可以吃什么| 促胃动力药什么时候吃| 查高血压挂什么科| 南岳什么山| 颈部有肿块看什么科室| 女人为什么会喷水| 默然是什么意思| 松板肉是什么肉| 心脏消融术是什么手术| 胎儿头位是什么意思| 鹦鹉为什么会说话| 平起平坐是什么动物| 什么药治高血压效果最好| 930是什么意思| 什么是姑息治疗| 喝什么茶可以降血脂| 脖子后面有痣代表什么| 月经期头疼是什么原因| 33年属什么生肖| 黄埔军校现在是什么学校| 右手小指戴戒指什么意思| 半夜喉咙痒咳嗽是什么原因| 肝郁有什么症状| 女人吃鹅蛋有什么好处| 右肋骨下方是什么器官| 反应蛋白高是什么意思| 女性做结扎手术对身体有什么危害| 农业户口和居民户口有什么区别| 冰心原名什么| 身份证带x是什么意思| 娃娃衫配什么裤子图片| 孩子咳嗽吃什么饭菜好| 寒胃有什么症状| 向日葵是什么| XXJ什么意思| 木字旁的字有什么| 牙龈为什么会萎缩| 梦见自己换衣服是什么意思| 吃巧克力有什么好处| 朱砂是什么意思| 什么原因导致宫外孕| trendiano什么牌子| 江苏有什么特产| 脂肪肝浸润是什么意思| 水蚤吃什么| 宝宝吐奶是什么原因引起的| 211什么意思| 冤家路窄是什么生肖| 当今社会什么行业前途比较好| 舌头发白有齿痕是什么原因| 黑色裤子配什么颜色t恤| 莫名其妙的心情不好是什么原因| 米非司酮片是什么药| 纯化水是什么水| 女生男相的是什么命| 农历五月初五是什么节| jo是什么意思| 紫苏有什么作用与功效| 有时候会感到莫名的难过是什么歌| 官杀是什么| 方兴未什么| 炎症是什么原因引起的| 毒是什么意思| 大肠在人体什么位置图| 7月4日是什么星座| 睾丸皮痒用什么药| cos是什么意思啊| 如果你是什么就什么造句| 尼麦角林片治什么病| land rover是什么车| 阴到炎用什么药好得快| 我还是什么| 仰望是什么意思| 精索炎吃什么药最好| 霖五行属什么| 堂哥的女儿叫什么| 7代表什么| 乌金是什么| 唇裂是什么原因造成的| 吃什么对肝脏好| 芙蓉花是什么花| 小孩小便红色是什么原因| 鼻子冒热气是什么原因| 百度

用车担心受罚 海归男驾闯红灯拖行交警20余米

百度 原标题:官方:科曼任命范迪克为荷兰队新任队长荷兰队主帅罗纳德-科曼确认,利物浦中卫范迪克将成为荷兰队的新任队长。

In mathematics and computer science, an algorithm (/??lɡ?r?e?m/ ?) is a finite sequence of mathematically rigorous instructions, typically used to solve a class of specific problems or to perform a computation.[1] Algorithms are used as specifications for performing calculations and data processing. More advanced algorithms can use conditionals to divert the code execution through various routes (referred to as automated decision-making) and deduce valid inferences (referred to as automated reasoning).

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.
Flowchart of using successive subtractions to find the greatest common divisor of number r and s

In contrast, a heuristic is an approach to solving problems without well-defined correct or optimal results.[2] For example, although social media recommender systems are commonly called "algorithms", they actually rely on heuristics as there is no truly "correct" recommendation.

As an effective method, an algorithm can be expressed within a finite amount of space and time[3] and in a well-defined formal language[4] for calculating a function.[5] Starting from an initial state and initial input (perhaps empty),[6] the instructions describe a computation that, when executed, proceeds through a finite[7] number of well-defined successive states, eventually producing "output"[8] and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.[9]

Etymology

edit

Around 825 AD, Persian scientist and polymath Mu?ammad ibn Mūsā al-Khwārizmī wrote kitāb al-?isāb al-hindī ("Book of Indian computation") and kitab al-jam' wa'l-tafriq al-?isāb al-hindī ("Addition and subtraction in Indian arithmetic"). In the early 12th century, Latin translations of these texts involving the Hindu–Arabic numeral system and arithmetic appeared, for example Liber Alghoarismi de practica arismetrice, attributed to John of Seville, and Liber Algorismi de numero Indorum, attributed to Adelard of Bath.[10] Here, alghoarismi or algorismi is the Latinization of Al-Khwarizmi's name;[1] the text starts with the phrase Dixit Algorismi, or "Thus spoke Al-Khwarizmi".[2]

The word algorism in English came to mean the use of place-value notation in calculations; it occurs in the Ancrene Wisse from circa 1225.[11] By the time Geoffrey Chaucer wrote The Canterbury Tales in the late 14th century, he used a variant of the same word in describing augrym stones, stones used for place-value calculation.[12][13] In the 15th century, under the influence of the Greek word ?ριθμ?? (arithmos, "number"; cf. "arithmetic"), the Latin word was altered to algorithmus.[14] By 1596, this form of the word was used in English, as algorithm, by Thomas Hood.[15]

Definition

edit

One informal definition is "a set of rules that precisely defines a sequence of operations",[16] which would include all computer programs (including programs that do not perform numeric calculations), and any prescribed bureaucratic procedure[17] or cook-book recipe.[18] In general, a program is an algorithm only if it stops eventually[19]—even though infinite loops may sometimes prove desirable. Boolos, Jeffrey & 1974, 1999 define an algorithm to be an explicit set of instructions for determining an output, that can be followed by a computing machine or a human who could only carry out specific elementary operations on symbols.[20]

Most algorithms are intended to be implemented as computer programs. However, algorithms are also implemented by other means, such as in a biological neural network (for example, the human brain performing arithmetic or an insect looking for food), in an electrical circuit, or a mechanical device.

History

edit

Ancient algorithms

edit

Step-by-step procedures for solving mathematical problems have been recorded since antiquity. This includes in Babylonian mathematics (around 2500 BC),[21] Egyptian mathematics (around 1550 BC),[21] Indian mathematics (around 800 BC and later),[22][23] the Ifa Oracle (around 500 BC),[24] Greek mathematics (around 240 BC),[25] Chinese mathematics (around 200 BC and later),[26] and Arabic mathematics (around 800 AD).[27]

The earliest evidence of algorithms is found in ancient Mesopotamian mathematics. A Sumerian clay tablet found in Shuruppak near Baghdad and dated to c.?2500 BC describes the earliest division algorithm.[21] During the Hammurabi dynasty c.?1800 – c.?1600 BC, Babylonian clay tablets described algorithms for computing formulas.[28] Algorithms were also used in Babylonian astronomy. Babylonian clay tablets describe and employ algorithmic procedures to compute the time and place of significant astronomical events.[29]

Algorithms for arithmetic are also found in ancient Egyptian mathematics, dating back to the Rhind Mathematical Papyrus c.?1550 BC.[21] Algorithms were later used in ancient Hellenistic mathematics. Two examples are the Sieve of Eratosthenes, which was described in the Introduction to Arithmetic by Nicomachus,[30][25]:?Ch 9.2? and the Euclidean algorithm, which was first described in Euclid's Elements (c.?300 BC).[25]:?Ch 9.1?Examples of ancient Indian mathematics included the Shulba Sutras, the Kerala School, and the Brāhmasphu?asiddhānta.[22]

The first cryptographic algorithm for deciphering encrypted code was developed by Al-Kindi, a 9th-century Arab mathematician, in A Manuscript On Deciphering Cryptographic Messages. He gave the first description of cryptanalysis by frequency analysis, the earliest codebreaking algorithm.[27]

Computers

edit

Weight-driven clocks

edit

Bolter credits the invention of the weight-driven clock as "the key invention [of Europe in the Middle Ages]," specifically the verge escapement mechanism[31] producing the tick and tock of a mechanical clock. "The accurate automatic machine"[32] led immediately to "mechanical automata" in the 13th century and "computational machines"—the difference and analytical engines of Charles Babbage and Ada Lovelace in the mid-19th century.[33] Lovelace designed the first algorithm intended for processing on a computer, Babbage's analytical engine, which is the first device considered a real Turing-complete computer instead of just a calculator. Although the full implementation of Babbage's second device was not realized for decades after her lifetime, Lovelace has been called "history's first programmer".

Electromechanical relay

edit

Bell and Newell (1971) write that the Jacquard loom, a precursor to Hollerith cards (punch cards), and "telephone switching technologies" led to the development of the first computers.[34] By the mid-19th century, the telegraph, the precursor of the telephone, was in use throughout the world. By the late 19th century, the ticker tape (c.?1870s) was in use, as were Hollerith cards (c. 1890). Then came the teleprinter (c.?1910) with its punched-paper use of Baudot code on tape.

Telephone-switching networks of electromechanical relays were invented in 1835. These led to the invention of the digital adding device by George Stibitz in 1937. While working in Bell Laboratories, he observed the "burdensome" use of mechanical calculators with gears. "He went home one evening in 1937 intending to test his idea... When the tinkering was over, Stibitz had constructed a binary adding device".[35][36]

Formalization

edit
 
Ada Lovelace's diagram from "Note G", the first published computer algorithm

In 1928, a partial formalization of the modern concept of algorithms began with attempts to solve the Entscheidungsproblem (decision problem) posed by David Hilbert. Later formalizations were framed as attempts to define "effective calculability"[37] or "effective method".[38] Those formalizations included the G?delHerbrandKleene recursive functions of 1930, 1934 and 1935, Alonzo Church's lambda calculus of 1936, Emil Post's Formulation 1 of 1936, and Alan Turing's Turing machines of 1936–37 and 1939.

Representations

edit

Algorithms can be expressed in many kinds of notation, including natural languages, pseudocode, flowcharts, drakon-charts, programming languages or control tables (processed by interpreters). 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.

Turing machines

edit

There are many possible representations and Turing machine programs can be expressed as a sequence of machine tables (see finite-state machine, state-transition table, and control table for more), as flowcharts and drakon-charts (see state diagram for more), as a form of rudimentary machine code or assembly code called "sets of quadruples", and more. Algorithm representations can also be classified into three accepted levels of Turing machine description: high-level description, implementation description, and formal description.[39] A high-level description describes the qualities of the algorithm itself, ignoring how it is implemented on the Turing machine.[39] An implementation description describes the general manner in which the machine moves its head and stores data to carry out the algorithm, but does not give exact states.[39] In the most detail, a formal description gives the exact state table and list of transitions of the Turing machine.[39]

Flowchart representation

edit

The graphical aid called a flowchart offers a way to describe and document an algorithm (and a computer program corresponding to it). It has four primary symbols: arrows showing program flow, rectangles (SEQUENCE, GOTO), diamonds (IF-THEN-ELSE), and dots (OR-tie). Sub-structures can "nest" in rectangles, but only if a single exit occurs from the superstructure.

Algorithmic analysis

edit

It is often important to know how much time, storage, or other cost an algorithm may require. Methods have been developed for the analysis of algorithms to obtain such quantitative answers (estimates); for example, an algorithm that adds up the elements of a list of n numbers would have a time requirement of ? ?, using big O notation. The algorithm only needs to remember two values: the sum of all the elements so far, and its current position in the input list. If the space required to store the input numbers is not counted, it has a space requirement of ? ?, otherwise ? ? is required.

Different algorithms may complete the same task with a different set of instructions in less or more time, space, or 'effort' than others. For example, a binary search algorithm (with cost ? ?) outperforms a sequential search (cost ? ? ) when used for table lookups on sorted lists or arrays.

Formal versus empirical

edit

The analysis, and study of algorithms is a discipline of computer science. Algorithms are often studied abstractly, without referencing any specific programming language or implementation. Algorithm analysis resembles other mathematical disciplines as 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 may be critical for algorithms designed for fast interactive, commercial, or long-life scientific usage. Scaling from small n to large n frequently 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 replace formal analysis, though, and are non-trivial to perform fairly.[40]

Execution efficiency

edit

To illustrate the potential improvements possible even in well-established algorithms, a recent significant innovation, relating to FFT algorithms (used heavily in the field of image processing), can decrease processing time up to 1,000 times for applications like medical imaging.[41] In general, speed improvements depend on special properties of the problem, which are very common in practical applications.[42] Speedups of this magnitude enable computing devices that make extensive use of image processing (like digital cameras and medical equipment) to consume less power.

Best Case and Worst Case

edit

The best case of an algorithm refers to the scenario or input for which the algorithm or data structure takes the least time and resources to complete its tasks.[43] The worst case of an algorithm is the case that causes the algorithm or data structure to consume the maximum period of time and computational resources.[44]

Design

edit

Algorithm design is a method or mathematical process for problem-solving and engineering algorithms. The design of algorithms is part of many solution theories, such as divide-and-conquer or dynamic programming within operation research. Techniques for designing and implementing algorithm designs are also called algorithm design patterns,[45] with examples including the template method pattern and the decorator pattern. One of the most important aspects of algorithm design is resource (run-time, memory usage) efficiency; the big O notation is used to describe e.g., an algorithm's run-time growth as the size of its input increases.[46]

Structured programming

edit

Per the Church–Turing thesis, any algorithm can be computed by any Turing complete model. Turing completeness only requires four instruction types—conditional GOTO, unconditional GOTO, assignment, HALT. However, Kemeny and Kurtz observe that, while "undisciplined" use of unconditional GOTOs and conditional IF-THEN GOTOs can result in "spaghetti code", a programmer can write structured programs using only these instructions; on the other hand "it is also possible, and not too hard, to write badly structured programs in a structured language".[47] Tausworthe augments the three B?hm-Jacopini canonical structures:[48] SEQUENCE, IF-THEN-ELSE, and WHILE-DO, with two more: DO-WHILE and CASE.[49] An additional benefit of a structured program is that it lends itself to proofs of correctness using mathematical induction.[50]

edit

By themselves, algorithms are not usually patentable. In the United States, a claim consisting solely of simple manipulations of abstract concepts, numbers, or signals does not constitute "processes" (USPTO 2006), so algorithms are not patentable (as in Gottschalk v. Benson). However practical applications of algorithms are sometimes patentable. For example, in Diamond v. Diehr, the application of a simple feedback algorithm to aid in the curing of synthetic rubber was deemed patentable. The patenting of software is controversial,[51] and there are criticized patents involving algorithms, especially data compression algorithms, such as Unisys's LZW patent. Additionally, some cryptographic algorithms have export restrictions (see export of cryptography).

Classification

edit

By implementation

edit
Recursion
A recursive algorithm invokes itself repeatedly until meeting a termination condition and is a common functional programming method. Iterative algorithms use repetitions such as loops or data structures like stacks to solve problems. Problems may be suited for one implementation or the other. The Tower of Hanoi is a puzzle commonly solved using recursive implementation. Every recursive version has an equivalent (but possibly more or less complex) iterative version, and vice versa.
Serial, parallel or distributed
Algorithms are usually discussed with the assumption that computers execute one instruction of an algorithm at a time on serial computers. Serial algorithms are designed for these environments, unlike parallel or distributed algorithms. Parallel algorithms take advantage of computer architectures where multiple processors can work on a problem at the same time. Distributed algorithms use multiple machines connected via a computer network. Parallel and distributed algorithms divide the problem into subproblems and collect the results back together. Resource consumption in these algorithms is not only processor cycles on each processor but also the communication overhead between the processors. Some sorting algorithms can be parallelized efficiently, but their communication overhead is expensive. Iterative algorithms are generally parallelizable, but some problems have no parallel algorithms and are called inherently serial problems.
Deterministic or non-deterministic
Deterministic algorithms solve the problem with exact decisions at every step; whereas non-deterministic algorithms solve problems via guessing. Guesses are typically made more accurate through the use of heuristics.
Exact or approximate
While many algorithms reach an exact solution, approximation algorithms seek an approximation that is close to the true solution. Such algorithms have practical value for many hard problems. For example, the Knapsack problem, where there is a set of items, and the goal is to pack the knapsack to get the maximum total value. Each item has some weight and some value. The total weight that can be carried is no more than some fixed number X. So, the solution must consider the weights of items as well as their value.[52]
Quantum algorithm
Quantum algorithms run on a realistic model of quantum computation. The term is usually used for those algorithms that seem inherently quantum or use some essential feature of Quantum computing such as quantum superposition or quantum entanglement.

By design paradigm

edit

Another way of classifying algorithms is by their design methodology or paradigm. Some common paradigms are:

Brute-force or exhaustive search
Brute force is a problem-solving method of systematically trying every possible option until the optimal solution is found. This approach can be very time-consuming, testing every possible combination of variables. It is often used when other methods are unavailable or too complex. Brute force can solve a variety of problems, including finding the shortest path between two points and cracking passwords.
Divide and conquer
A divide-and-conquer algorithm repeatedly reduces a problem to one or more smaller instances of itself (usually recursively) until the instances are small enough to solve easily. Merge sorting is an example of divide and conquer, where an unordered list is repeatedly split into smaller lists, which are sorted in the same way and then merged.[53] In a simpler variant of divide and conquer called prune and search or decrease-and-conquer algorithm, which solves one smaller instance of itself, and does not require a merge step.[54] An example of a prune and search algorithm is the binary search algorithm.
Search and enumeration
Many problems (such as playing chess) can be modelled as problems on graphs. A graph exploration algorithm specifies rules for moving around a graph and is useful for such problems. This category also includes search algorithms, branch and bound enumeration, and backtracking.
Randomized algorithm
Such algorithms make some choices randomly (or pseudo-randomly). They find approximate solutions when finding exact solutions may be impractical (see heuristic method below). For some problems, the fastest approximations must involve some randomness.[55] Whether randomized algorithms with polynomial time complexity can be the fastest algorithm for some problems is an open question known as the P versus NP problem. There are two large classes of such algorithms:
  1. Monte Carlo algorithms return a correct answer with high probability. E.g. RP is the subclass of these that run in polynomial time.
  2. Las Vegas algorithms always return the correct answer, but their running time is only probabilistically bound, e.g. ZPP.
Reduction of complexity
This technique transforms difficult problems into better-known problems solvable with (hopefully) asymptotically optimal algorithms. The goal is to find a reducing algorithm whose complexity is not dominated by the resulting reduced algorithms. For example, one selection algorithm finds the median of an unsorted list by first sorting the list (the expensive portion), and then pulling out the middle element in the sorted list (the cheap portion). This technique is also known as transform and conquer.
Back tracking
In this approach, multiple solutions are built incrementally and abandoned when it is determined that they cannot lead to a valid full solution.

Optimization problems

edit

For optimization problems there is a more specific classification of algorithms; an algorithm for such problems may fall into one or more of the general categories described above as well as into one of the following:

Linear programming
When searching for optimal solutions to a linear function bound by linear equality and inequality constraints, the constraints can be used directly to produce optimal solutions. There are algorithms that can solve any problem in this category, such as the popular simplex algorithm.[56] Problems that can be solved with linear programming include the maximum flow problem for directed graphs. If a problem also requires that any of the unknowns be integers, then it is classified in integer programming. A linear programming algorithm can solve such a problem if it can be proved that all restrictions for integer values are superficial, i.e., the solutions satisfy these restrictions anyway. In the general case, a specialized algorithm or an algorithm that finds approximate solutions is used, depending on the difficulty of the problem.
Dynamic programming
When a problem shows optimal substructures—meaning the optimal solution can be constructed from optimal solutions to subproblems—and overlapping subproblems, meaning the same subproblems are used to solve many different problem instances, a quicker approach called dynamic programming avoids recomputing solutions. For example, Floyd–Warshall algorithm, the shortest path between a start and goal vertex in a weighted graph can be found using the shortest path to the goal from all adjacent vertices. Dynamic programming and memoization go together. Unlike divide and conquer, dynamic programming subproblems often overlap. The difference between dynamic programming and simple recursion is the caching or memoization of recursive calls. When subproblems are independent and do not repeat, memoization does not help; hence dynamic programming is not applicable to all complex problems. Using memoization dynamic programming reduces the complexity of many problems from exponential to polynomial.
The greedy method
Greedy algorithms, similarly to a dynamic programming, work by examining substructures, in this case not of the problem but of a given solution. Such algorithms start with some solution and improve it by making small modifications. For some problems, they always find the optimal solution but for others they may stop at local optima. The most popular use of greedy algorithms is finding minimal spanning trees of graphs without negative cycles. Huffman Tree, Kruskal, Prim, Sollin are greedy algorithms that can solve this optimization problem.
The heuristic method
In optimization problems, heuristic algorithms find solutions close to the optimal solution when finding the optimal solution is impractical. These algorithms get closer and closer to the optimal solution as they progress. In principle, if run for an infinite amount of time, they will find the optimal solution. They can ideally find a solution very close to the optimal solution in a relatively short time. These algorithms include local search, tabu search, simulated annealing, and genetic algorithms. Some, like simulated annealing, are non-deterministic algorithms while others, like tabu search, are deterministic. When a bound on the error of the non-optimal solution is known, the algorithm is further categorized as an approximation algorithm.

Examples

edit

One of the simplest algorithms finds the largest number in a list of numbers of random order. Finding the solution requires looking at every number in the list. From this follows a simple algorithm, which can be described in plain English as:

High-level description:

  1. If a set of numbers is empty, then there is no highest number.
  2. Assume the first number in the set is the largest.
  3. For each remaining number in the set: if this number is greater than the current largest, it becomes the new largest.
  4. When there are no unchecked numbers left in the set, consider the current largest number to be the largest in the set.

(Quasi-)formal description: Written in prose but much closer to the high-level language of a computer program, the following is the more formal coding of the algorithm in pseudocode or pidgin code:

Algorithm LargestNumber
Input: A list of numbers L.
Output: The largest number in the list L.
if L.size = 0 return null
largestL[0]
for each item in L, do
    if item > largest, then
        largestitem
return largest
  • "←" denotes assignment. For instance, "largestitem" means that the value of largest changes to the value of item.
  • "return" terminates the algorithm and outputs the following value.

See also

edit

Notes

edit
  1. ^ a b "Definition of ALGORITHM". Merriam-Webster Online Dictionary. Archived from the original on February 14, 2020. Retrieved November 14, 2019.
  2. ^ a b David A. Grossman, Ophir Frieder, Information Retrieval: Algorithms and Heuristics, 2nd edition, 2004, ISBN 1402030045
  3. ^ "Any classical mathematical algorithm, for example, can be described in a finite number of English words" (Rogers 1987:2).
  4. ^ 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).
  5. ^ "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 1987:1).
  6. ^ "An algorithm has zero or more inputs, i.e., quantities which are given to it initially before the algorithm begins" (Knuth 1973:5).
  7. ^ "A procedure which has all the characteristics of an algorithm except that it possibly lacks finiteness may be called a 'computational method'" (Knuth 1973:5).
  8. ^ "An algorithm has one or more outputs, i.e., quantities which have a specified relation to the inputs" (Knuth 1973:5).
  9. ^ 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).
  10. ^ Blair, Ann, Duguid, Paul, Goeing, Anja-Silvia and Grafton, Anthony. Information: A Historical Companion, Princeton: Princeton University Press, 2021. p. 247
  11. ^ "algorism". Oxford English Dictionary. Retrieved May 18, 2025.
  12. ^ Chaucer, Geoffrey. "The Miller's Tale". Line 3210.
  13. ^ 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.
  14. ^ 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 9789400776548.
  15. ^ "algorithm". Oxford English Dictionary. Retrieved May 18, 2025.
  16. ^ Stone (1971), p. 8.
  17. ^ 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 9780262536370. Archived from the original on December 22, 2019. Retrieved May 27, 2019. [...] the next level of abstraction of central bureaucracy: globally operating algorithms.
  18. ^ Dietrich, Eric (1999). "Algorithm". In Wilson, Robert Andrew; Keil, Frank C. (eds.). The MIT Encyclopedia of the Cognitive Sciences. MIT Cognet library. Cambridge, Massachusetts: MIT Press (published 2001). p. 11. ISBN 9780262731447. Retrieved July 22, 2020. An algorithm is a recipe, method, or technique for doing something.
  19. ^ Stone requires that "it must terminate in a finite number of steps" (Stone 1973:7–8).
  20. ^ Boolos and Jeffrey 1974, 1999:19
  21. ^ 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 9783642181924.
  22. ^ 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.
  23. ^ Hayashi, T. (2023, January 1). Brahmagupta. Encyclopedia Britannica.
  24. ^ 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.
  25. ^ a b c Cooke, Roger L. (2005). The History of Mathematics: A Brief Course. John Wiley & Sons. ISBN 978-1-118-46029-0.
  26. ^ Chabert, Jean-Luc, ed. (1999). "A History of Algorithms". SpringerLink. doi:10.1007/978-3-642-18192-4. ISBN 978-3-540-63369-3.
  27. ^ a b Dooley, John F. (2013). A Brief History of Cryptology and Cryptographic Algorithms. Springer Science & Business Media. pp. 12–3. ISBN 9783319016283.
  28. ^ 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.
  29. ^ Aaboe, Asger (2001). Episodes from the Early History of Astronomy. New York: Springer. pp. 40–62. ISBN 978-0-387-95136-2.
  30. ^ Ast, Courtney. "Eratosthenes". Wichita State University: Department of Mathematics and Statistics. Archived from the original on February 27, 2015. Retrieved February 27, 2015.
  31. ^ Bolter 1984:24
  32. ^ Bolter 1984:26
  33. ^ Bolter 1984:33–34, 204–206.
  34. ^ Bell and Newell diagram 1971:39, cf. Davis 2000
  35. ^ Melina Hill, Valley News Correspondent, A Tinkerer Gets a Place in History, Valley News West Lebanon NH, Thursday, March 31, 1983, p. 13.
  36. ^ Davis 2000:14
  37. ^ Kleene 1943 in Davis 1965:274
  38. ^ Rosser 1939 in Davis 1965:225
  39. ^ a b c d Sipser 2006:157
  40. ^ 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.
  41. ^ Gillian Conahan (January 2013). "Better Math Makes Faster Data Networks". discovermagazine.com. Archived from the original on May 13, 2014. Retrieved May 13, 2014.
  42. ^ 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.
  43. ^ "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.
  44. ^ "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.
  45. ^ 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.
  46. ^ "Big-O notation (article) | Algorithms". Khan Academy. Retrieved June 3, 2024.
  47. ^ John G. Kemeny and Thomas E. Kurtz 1985 Back to Basic: The History, Corruption, and Future of the Language, Addison-Wesley Publishing Company, Inc. Reading, MA, ISBN 0-201-13433-0.
  48. ^ Tausworthe 1977:101
  49. ^ Tausworthe 1977:142
  50. ^ Knuth 1973 section 1.2.1, expanded by Tausworthe 1977 at pages 100ff and Chapter 9.1
  51. ^ "The Experts: Does the Patent System Encourage Innovation?". The Wall Street Journal. May 16, 2013. ISSN 0099-9660. Retrieved March 29, 2017.
  52. ^ 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.
  53. ^ Goodrich, Michael T.; Tamassia, Roberto (2001). "5.2 Divide and Conquer". Algorithm Design: Foundations, Analysis, and Internet Examples. John Wiley & Sons. p. 263. ISBN 9780471383659.
  54. ^ Goodrich & Tamassia (2001), p. 245, 4.7.1 Prune-and-search.
  55. ^ 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. CiteSeerX 10.1.1.145.4600. doi:10.1145/102782.102783. S2CID 13268711.
  56. ^ George B. Dantzig and Mukund N. Thapa. 2003. Linear Programming 2: Theory and Extensions. Springer-Verlag.

Bibliography

edit

Further reading

edit
edit
Algorithm repositories
正装是什么样的衣服 老三篇是什么意思 尿酸高可以吃什么鱼 什么的眼睛填空 数字五行属什么
河图洛书是什么意思 过敏有什么症状表现 什么病会吐血 桂鱼吃什么食物 大小便失禁是什么原因
氨基酸是什么 1996年出生属什么生肖 西南方向是什么方位 咖啡有什么作用和功效 日语亚麻跌是什么意思
无致病菌生长是什么意思 公安局局长是什么级别 看高血压挂什么科 胃有灼烧感是什么原因 脾气是什么意思
1985年属牛是什么命hcv9jop6ns4r.cn 白水晶五行属什么hcv7jop6ns3r.cn 吃什么润肺养肺最快dajiketang.com 安踏是什么品牌hcv8jop3ns3r.cn 狂鸟读什么baiqunet.com
没字去掉三点水念什么hcv8jop3ns3r.cn 西楚霸王是什么生肖hcv8jop7ns5r.cn 什么不绝hcv8jop5ns0r.cn 金达莱花是什么花hcv9jop4ns0r.cn 语言障碍挂什么科hcv9jop6ns0r.cn
早上出汗是什么原因hcv9jop2ns9r.cn 氯高是什么原因qingzhougame.com 五行缺木是什么命xianpinbao.com 么么哒是什么意思hcv8jop8ns8r.cn 大便很细是什么原因520myf.com
眩晕挂号挂什么科mmeoe.com 水晶和玻璃有什么区别hkuteam.com ppada是什么牌子hcv8jop7ns9r.cn 金生水是什么意思gysmod.com 小腿前侧肌肉叫什么hcv8jop8ns0r.cn
百度