數據架構
該庫提供了經典算法和數據架構的實現。
組織
該項目分為兩個軟件包:算法和結構。算法軟件包包含大部分獨立算法的實現,而結構軟件包包含僅在其上運行的數據結構和算法。
演算法
這是算法軟件包下的算法列表:
在binarysearch.py中:
- 標準二進制搜索:標準二進制搜索。 https://en.wikipedia.org/wiki/binary_search_algorithm
- 第一次出現二進制搜索:標準二進制搜索,除了它找到與搜索鍵匹配的第一個元素。
在expression.py中:
在Quessionolver.py中:
- A*算法:找到算法的路徑。 https://en.wikipedia.org/wiki/a* _search_algorithm
- a*算法適應8個式問題問題:https://www.cs.princeton.edu/courses/archive/spr10/cos226/assignments/8puzzle.html
sort.py:
- 選擇排序:https://en.wikipedia.org/wiki/selection_sort
- 插入排序:https://en.wikipedia.org/wiki/insertion_sort
- 外殼排序:https://en.wikipedia.org/wiki/shellsort
- 合併排序的變化:https://en.wikipedia.org/wiki/merge_sort
- 反轉計數:計數具有修改合併排序的反轉數
- 快速排序的變化:包括標準快速排序,3向快速排序和採樣快速排序。 https://en.wikipedia.org/wiki/quicksort
- 堆排序:https://en.wikipedia.org/wiki/heapsort
- 選擇KTH:按順序選擇KTH元素。基於快速排序分區。
結構
這是在它們上運行的已實施數據結構和算法的列表:
在linkedlist.py中:
- 鏈接列表:https://en.wikipedia.org/wiki/linked_list
- 鏈接堆棧:用鏈接列表實現的堆棧。
- 鏈接隊列:用鏈接列表實現的隊列。
在unionfind.py中:https://en.wikipedia.org/wiki/disjoint-set_data_structure
- 快速查找:使用數組之類的數據結構實現的脫節集。 o(1)查找。
- 快速聯合:使用父鏈接樹實現的脫節集。
- 平衡的快速聯合:與父鏈接樹實現並在聯合上平衡的脫節集。 o(log(n))查找和聯合效率。
- 路徑壓縮快速聯合:與父鏈接樹實現並通過路徑壓縮進行增強。
- 平衡路徑壓縮快速聯合:與父鏈接樹實現的脫節集和平衡和路徑壓縮。幾乎攤銷的O(1)在查找和聯合方面效率。
在Symboltable.py中:
- 二進制搜索樹:標準BST。 https://en.wikipedia.org/wiki/binary_search_tree
- 紅色和黑樹:使用2-3表示的平衡BST。 https://en.wikipedia.org/wiki/red%E2%80%93Black_tree
- 單獨的鍊式哈希表:哈希表通過將它們鏈接在列表中來解決碰撞。 https://en.wikipedia.org/wiki/hash_table#separate_chaining
- 開放地址哈希表:用線性探測解決碰撞的哈希表。 https://en.wikipedia.org/wiki/hash_table#open_addressing
在堆中:
- 二進制堆:用二進制堆的優先隊列實現。 https://en.wikipedia.org/wiki/binary_heap
在Graph.py中:
- 無向圖:https://en.wikipedia.org/wiki/graph_(Discrete_mathematics)#undirected_graph
- 定向圖:https://en.wikipedia.org/wiki/graph_(discrete_mathematics)#directed_graph
- 無方向的加權圖:https://en.wikipedia.org/wiki/graph_(discrete_mathematics)#Weighted_graph
- 定向加權圖:https://en.wikipedia.org/wiki/graph_(Discrete_mathematics)#Weighted_graph
- 深度搜索:https://en.wikipedia.org/wiki/depth-first_search
- 廣度首次搜索:https://en.wikipedia.org/wiki/breadth-first_search
- 無向連接組件:https://en.wikipedia.org/wiki/component_(graph_theory)
- 無向周期檢測:https://en.wikipedia.org/wiki/cycle_(graph_theory)
- 定向周期檢測:https://en.wikipedia.org/wiki/cycle_(graph_theory)
- 雙黨檢測:https://en.wikipedia.org/wiki/bipartite_graph
- 拓撲排序:https://en.wikipedia.org/wiki/topology_sorting
- 緊密連接的組件(Kosaraju的算法):https://en.wikipedia.org/wiki/kosaraju%27S_ALGORITHM
- PRIM的算法(懶惰):https://en.wikipedia.org/wiki/prim%27S_ALGORITHM
- Kruskal的算法:https://en.wikipedia.org/wiki/kruskal%27S_ALGORITHM
- Dijkstra的最短路徑:https://en.wikipedia.org/wiki/dijkstra%27s_algorithm
- 拓撲無環最短路徑:https://en.wikipedia.org/wiki/topologice_sorting#application_to_shortest_path_finding
- 貝爾曼·福特(Bellman Ford
用法
所有組件均已測試。但是,它們未經過嚴格的生產標準測試。諸如鍊接列表和Symboltables之類的數據結構具有標準Python列表和字典等接口。