1. 程式人生 > >程式設計的32個演算法

程式設計的32個演算法

1.A* 搜尋演算法——圖形搜尋演算法,從給定起點到給定終點計算出路徑。其中使用了一種啟發式的估算,為每個節點估算通過該節點的最佳路徑,並以之為各個地點排定次序。演算法以得到的次序訪問這些節點。因此,A*搜尋演算法是最佳優先搜尋的範例。 Graph search algorithm that finds a path from a given initial node to a given goal node. It employs a heuristic estimate that ranks each node by an estimate of the best route that goes through that node. It visits the nodes in order of this heuristic estimate. The A* algorithm is therefore an example of best-first search.
  2.集束搜尋(又名定向搜尋,Beam Search)——最佳優先搜尋演算法的優化。使用啟發式函式評估它檢查的每個節點的能力。不過,集束搜尋只能在每個深度中發現最前面的m個最符合條件的節點,m是固定數字——集束的寬度。 Beam search is a search algorithm that is an optimization of best-first search. Like best-first search, it uses a heuristic function to evaluate the promise of each node it examines. Beam search, however, only unfolds the first m most promising nodes at each depth, where m is a fixed number, the beam width.
  3.二分查詢(Binary Search)——線上性陣列中找特定值的演算法,每個步驟去掉一半不符合要求的資料。這個是學習C語言時經常用到的演算法之一了,也非常經典。 Technique for finding a particular value in a linear array, by ruling out half of the data at each step.   4.分支界定演算法(Branch and Bound)——在多種最優化問題中尋找特定最優化解決方案的演算法,特別是針對離散、組合的最優化。 A general algorithmic method for finding optimal solutions of various optimization problems, especially in discrete and combinatorial optimization.
  5.Buchberger演算法——一種數學演算法,可將其視為針對單變數最大公約數求解的歐幾里得演算法和線性系統中高斯消元法的泛化。 In computational algebraic geometry and computational commutative algebra, Buchberger's algorithm is a method of transforming a given set of generators for a polynomial ideal into a Gröbner basis with respect to some monomial order. One can view it as a generalization of the Euclidean algorithm for univariate gcd computation and of Gaussian elimination for linear systems.   6.資料壓縮——採取特定編碼方案,使用更少的位元組數(或是其他資訊承載單元)對資訊編碼的過程,又叫來源編碼。 Data compression or source coding is the process of encoding information using fewer bits (or other information-bearing units) than an unencoded representation would use through use of specific encoding schemes.   7.Diffie-Hellman金鑰交換演算法——一種加密協議,允許雙方在事先不瞭解對方的情況下,在不安全的通訊通道中,共同建立共享金鑰。該金鑰以後可與一個對稱密碼一起,加密後續通訊。 Cryptographic protocol which allows two parties that have no prior knowledge of each other to jointly establish a shared secret key over an insecure communications channel. This key can then be used to encrypt subsequent communications using a symmetric key cipher.   8.Dijkstra演算法——針對沒有負值權重邊的有向圖,計算其中的單一起點最短演算法。 Algorithm that solves the single-source shortest path problem for a directed graph with nonnegative edge weights.   9.離散微分演算法(Discrete differentiation) 就像計算f'(x) = (f(x+h) - f(x-h)) / 2h公式那樣的問題。 I.e., the formula f'(x) = (f(x+h) - f(x-h)) / 2h.   10.動態規劃演算法(Dynamic Programming)——展示互相覆蓋的子問題和最優子架構演算法 Dynamic programming is a method for reducing the runtime of algorithms exhibiting the properties of overlapping subproblems and optimal substructure, described below.   11.歐幾里得演算法(Euclidean algorithm)——計算兩個整數的最大公約數。最古老的演算法之一,出現在公元前300前歐幾里得的《幾何原本》。 Algorithm to determine the greatest common divisor (gcd) of two integers. It is one of the oldest algorithms known, since it appeared in Euclid's Elements around 300 BC. The algorithm does not require factoring the two integers.   12.期望-最大演算法(Expectation-maximization algorithm,又名EM-Training)——在統計計算中,期望-最大演算法在概率模型中尋找可能性最大的引數估算值,其中模型依賴於未發現的潛在變數。EM在兩個步驟中交替計算,第一步是計算期望,利用對隱藏變數的現有估計值,計算其最大可能估計值;第二步是最大化,最大化在第一步上求得的最大可能值來計算引數的值。 In statistical computing, an expectation-maximization (EM) algorithm is an algorithm for finding maximum likelihood estimates of parameters in probabilistic models, where the model depends on unobserved latent variables. EM alternates between performing an expectation step, which computes the expected value of the latent variables, and a maximization step, which computes the maximum likelihood estimates of the parameters given the data and setting the latent variables to their expectation.   13.快速傅立葉變換(Fast Fourier transform,FFT)——計算離散的傅立葉變換(DFT)及其反轉。該演算法應用範圍很廣,從數字訊號處理到解決偏微分方程,到快速計算大整數乘積。 Efficient algorithm to compute the discrete Fourier transform (DFT) and its inverse. FFTs are of great importance to a wide variety of applications, from digital signal processing to solving partial differential equations to algorithms for quickly multiplying large integers.   14.梯度下降(Gradient descent)——一種數學上的最優化演算法。 Gradient descent is an optimization algorithm that approaches a local minimum of a function by taking steps proportional to the negative of the gradient (or the approximate gradient) of the function at the current point. If instead one takes steps proportional to the gradient, one approaches a local maximum of that function; the procedure is then known as gradient ascent.   15.雜湊演算法(Hashing) A function for summarizing or probabilistically identifying data. Typically this means one applies a mathematical formula to the data, producing a string which is probably more or less unique to that data. The string is much shorter than the original data, but can be used to uniquely identify it.   16.堆排序(Heaps) In computer science a heap is a specialized tree-based data structure. Heaps are favourite data structures for many applications: Heap sort, selection algorithms (finding the min, max or both of them, median or even any kth element in sublinear time), graph algorithms.   17.Karatsuba乘法——需要完成上千位整數的乘法的系統中使用,比如計算機代數系統和大數程式庫,如果使用長乘法,速度太慢。該演算法發現於1962年。 For systems that need to multiply numbers in the range of several thousand digits, such as computer algebra systems and bignum libraries, long multiplication is too slow. These systems employ Karatsuba multiplication, which was discovered in 1962.   18.LLL演算法(Lenstra-Lenstra-Lovasz  lattice reduction)——以格規約(lattice)基數為輸入,輸出短正交向量基數。LLL演算法在以下公共金鑰加密方法中有大量使用:揹包加密系統(knapsack)、有特定設定的RSA加密等等。 The Lenstra-Lenstra-Lovasz lattice reduction (LLL) algorithm is an algorithm which, given a lattice basis as input, outputs a basis with short, nearly orthogonal vectors. The LLL algorithm has found numerous applications in cryptanalysis of public-key encryption schemes: knapsack cryptosystems, RSA with particular settings, and so forth.   19.最大流量演算法(Maximum flow)——該演算法試圖從一個流量網路中找到最大的流。它優勢被定義為找到這樣一個流的值。最大流問題可以看作更復雜的網路流問題的特定情況。最大流與網路中的介面有關,這就是最大流-最小截定理(Max-flow min-cut theorem)。Ford-Fulkerson 能找到一個流網路中的最大流。 The maximum flow problem is finding a legal flow through a flow network that is maximal. Sometimes it is defined as finding the value of such a flow. The maximum flow problem can be seen as special case of more complex network flow problems. The maximal flow is related to the cuts in a network by the Max-flow min-cut theorem. The Ford-Fulkerson algorithm computes the maximum flow in a flow network.   20.合併排序(Merge Sort) A sorting algorithm for rearranging lists (or any other data structure that can only be accessed sequentially, e.g. file streams) into a specified order.   21.牛頓法(Newton's method)——求非線性方程(組)零點的一種重要的迭代法。 Efficient algorithm for finding approximations to the zeros (or roots) of a real-valued function. Newton's method is also a well-known algorithm for finding roots of equations in one or more dimensions. It can also be used to find local maxima and local minima of functions.   22.Q-learning學習演算法——這是一種通過學習動作值函式(action-value function)完成的強化學習演算法,函式採取在給定狀態的給定動作,並計算出期望的效用價值,在此後遵循固定的策略。Q-leanring的優勢是,在不需要環境模型的情況下,可以對比可採納行動的期望效用。 Q-learning is a reinforcement learning technique that works by learning an action-value function that gives the expected utility of taking a given action in a given state and following a fixed policy thereafter. A strength with Q-learning is that it is able to compare the expected utility of the available actions without requiring a model of the environment.     23.兩次篩法(Quadratic Sieve)——現代整數因子分解演算法,在實踐中,是目前已知第二快的此類演算法(僅次於數域篩法Number Field Sieve)。對於110位以下的十位整數,它仍是最快的,而且都認為它比數域篩法更簡單。 The quadratic sieve algorithm (QS) is a modern integer factorization algorithm and, in practice, the second fastest method known (after the number field sieve, NFS). It is still the fastest for integers under 110 decimal digits or so, and is considerably simpler than the number field sieve.   24.RANSAC——是“RANdom SAmple Consensus”的縮寫。該演算法根據一系列觀察得到的資料,資料中包含異常值,估算一個數學模型的引數值。其基本假設是:資料包含非異化值,也就是能夠通過某些模型引數解釋的值,異化值就是那些不符合模型的資料點。 RANSAC is an abbreviation for "RANdom SAmple Consensus". It is an algorithm to estimate parameters of a mathematical model from a set of observed data which contains "outliers". A basic assumption is that the data consists of "inliers", i. e., data points which can be explained by some set of model parameters, and "outliers" which are data points that do not fit the model.   25.RSA——公鑰加密演算法。首個適用於以簽名作為加密的演算法。RSA在電商行業中仍大規模使用,大家也相信它有足夠安全長度的公鑰。 Algorithm for public-key encryption. It was the first algorithm known to be suitable for signing as well as encryption. RSA is still widely used in electronic commerce protocols, and is believed to be secure given sufficiently long keys.   26.Schönhage-Strassen演算法——在數學中,Schönhage-Strassen演算法是用來完成大整數的乘法的快速漸近演算法。其演算法複雜度為:O(N log(N) log(log(N))),該演算法使用了傅立葉變換。 In mathematics, the Schönhage-Strassen algorithm is an asymptotically fast method for multiplication of large integer numbers. The run-time is O(N log(N) log(log(N))). The algorithm uses Fast Fourier Transforms in rings.   27.單純型演算法(Simplex Algorithm)——在數學的優化理論中,單純型演算法是常用的技術,用來找到線性規劃問題的數值解。線性規劃問題包括在一組實變數上的一系列線性不等式組,以及一個等待最大化(或最小化)的固定線性函式。 In mathematical optimization theory, the simplex algorithm a popular technique for numerical solution of the linear programming problem. A linear programming problem consists of a collection of linear inequalities on a number of real variables and a fixed linear functional which is to be maximized (or minimized).   28.奇異值分解(Singular value decomposition,簡稱SVD)——線上性代數中,SVD是重要的實數或複數矩陣的分解方法,在訊號處理和統計中有多種應用,比如計算矩陣的偽逆矩陣(以求解最小二乘法問題)、解決超定線性系統(overdetermined linear systems)、矩陣逼近、數值天氣預報等等。 In linear algebra, SVD is an important factorization of a rectangular real or complex matrix, with several applications in signal processing and statistics, e.g., computing the pseudoinverse of a matrix (to solve the least squares problem), solving overdetermined linear systems, matrix approximation, numerical weather prediction.   29.求解線性方程組(Solving a system of linear equations)——線性方程組是數學中最古老的問題,它們有很多應用,比如在數字訊號處理、線性規劃中的估算和預測、數值分析中的非線性問題逼近等等。求解線性方程組,可以使用高斯—約當消去法(Gauss-Jordan elimination),或是柯列斯基分解( Cholesky decomposition)。 Systems of linear equations belong to the oldest problems in mathematics and they have many applications, such as in digital signal processing, estimation, forecasting and generally in linear programming and in the approximation of non-linear problems in numerical analysis. An efficient way to solve systems of linear equations is given by the Gauss-Jordan elimination or by the Cholesky decomposition.   30.Strukturtensor演算法——應用於模式識別領域,為所有畫素找出一種計算方法,看看該畫素是否處於同質區域( homogenous region),看看它是否屬於邊緣,還是是一個頂點。 In pattern recognition: Computes a measure for every pixel which tells you if this pixel is located in a homogenous region, if it belongs to an edge, or if it is a vertex.   31.合併查詢演算法(Union-find)——給定一組元素,該演算法常常用來把這些元素分為多個分離的、彼此不重合的組。不相交集(disjoint-set)的資料結構可以跟蹤這樣的切分方法。合併查詢演算法可以在此種資料結構上完成兩個有用的操作:查詢:判斷某特定元素屬於哪個組。合併:聯合或合併兩個組為一個組。 Given a set of elements, it is often useful to partition them into a number of separate, nonoverlapping groups. A disjoint-set data structure is a data structure that keeps track of such a partitioning. A union-find algorithm is an algorithm that performs two useful operations on such a data structure:  Find: Determine which group a particular element is in.  Union: Combine or merge two groups into a single group.   32.維特比演算法(Viterbi algorithm)——尋找隱藏狀態最有可能序列的動態規劃演算法,這種序列被稱為維特比路徑,其結果是一系列可以觀察到的事件,特別是在隱藏的Markov模型中。 Dynamic programming algorithm for finding the most likely sequence of hidden states - known as the Viterbi path - that result in a sequence of observed events, especially in the context of hidden Markov models.