[[wp>Algorithm|演算法]]需考慮到以下幾點: * 時間複雜度 * 空間複雜度 ====== Big O ====== ====== Sorting ====== * [[wp>Sorting algorithm]] * [[wp>Bubble sort]] * [[wp>Quicksort]] * [[wp>Bucket sort]] $n\log n$ ====== Search ====== * [[wp>Search algorithm]] * [[wp>Binary search algorithm]] * 針對已排序的串列進行搜尋。先與中間元素比較,根據結果與前列或是後列進行遞迴。 * [[wp>Breadth-first search]] * 依序搜尋下層節點。使用 FIFO 佇列。 * 將根節點放入佇列。 * 從佇列中取出節點,檢視是否為目標。若否,將其相鄰節點依序放入佇列。重複此步驟直到佇列為空。 * [[wp>Depth-first search]] * 優先搜索至葉節點。使用 LIFO 堆疊。 * 若葉節點不是目標,退回至最近的節點進行遞迴。 ====== Graph ====== * [[wp>Shortest path problem]] * [[wp>Dijkstra's algorithm]] * 適用於給定起點,且圖中沒有權重為負的邊。 * [[wp>Bellman–Ford algorithm]] * 相對於 Dijkstra's algorithm,可以處理邊上權重為負的圖。 * [[wp>Floyd–Warshall algorithm]] * 原理為動態規劃 (dynamic programming)。 * 適用於求全局最短路径问题。 * [[wp>Strongly connected component]] * [[wp>Minimum cut]] ====== Greedy algorithm ====== * [[wp>Greedy algorithm]] * 適用於局部最佳解可決定全局最佳解的問題。 * 演算法的下一步都是選擇當下 (局部) 最佳解。 * [[wp>Shortest path problem]] * [[wp>Dijkstra's algorithm]] * [[wp>Minimum spanning tree]] * [[wp>Kruskal's algorithm]] * [[wp>Prim's algorithm]] * [[wp>Huffman coding]] * [[http://www.csie.ntnu.edu.tw/~u91029/Greedy.html|演算法筆記: 貪婪演算法]] ====== Dynamic Programming ====== * [[wp>Dynamic programming]] * DP = Divide and Conquer + Memoization * 適用於具有[[wp>Optimal_substructure|最佳子結構 (optimal substructure)]] 和[[wp>Overlapping subproblems|重疊子問題 (overlapping subproblems)]] 的問題。 * 一個問題切割成數個子問題,其中子問題有所重複,為避免重複計算,動態規劃會將計算結果紀錄成表。演算法過程中會持續查表並加以更新,最終求得解。 * [[wp>Tower of Hanoi]] * [[wp>Fibonacci number]] * 遞迴求解過程中,重複解子問題,可動態規劃以減低計算量。 * [[wp>Matrix chain multiplication]] * [[http://www.csie.ntnu.edu.tw/~u91029/DynamicProgramming.html|演算法筆記: 動態規劃]] * [[http://www.avatar.se/molbioinfo2001/dynprog/dynamic.html]] ====== Integer Programming ====== * [[wp>Linear programming]] * 問題包含目標函數和約束條件,若兩者皆可以用線性方程表示,則可以用線性規劃 (linear programming) 求解。 * [[wp>Travelling salesman problem]] * [[wp>Vertex cover]] * [[wp>Boolean satisfiability problem]] ====== P and NP ====== ====== Distributed Algorithm ====== - 定義語意 (semantic) - 定義操作 (operation) - 假設有哪些失敗 * [[https://iiswww.iis.sinica.edu.tw/page/events/FILE/120116.pdf|The Power of Abstraction]] * [[http://www.youtube.com/watch?v=OOM71I0cYW0|Security of Internet Storage]] * [[wp>Byzantine fault tolerance]] * [[http://www.amazon.com/Distributed-Algorithms-Kaufmann-Management-Systems/dp/1558603484|Distributed Algorithms]] ====== 基本問題 ====== ===== 河內塔 ===== * [[http://openhome.cc/Gossip/AlgorithmGossip/HanoiTower.htm|河內塔]] * [[http://www.csie.ntnu.edu.tw/~u91029/DivideAndConquer.html|演算法筆記: Tower of Hanoi]] ====== 外部連結 ====== * [[http://www.csie.ntnu.edu.tw/~u91029/index.html|演算法筆記]] * [[http://openhome.cc/Gossip/AlgorithmGossip/|非關語言: 常見程式演算]]