
Algorithms & data structures project
Algorithms and data structures are amongst the most fundamental ingredients in the recipe for efficient code and good software design; knowledge of how to create and design excellent algorithms is an essential skill required in becoming an exemplary programmer. The goal of this repository is to demonstrate how to correctly implement the most common data structures and algorithms in the simplest and most elegant ways.
This repository is contribution friendly 😃. If you're an algorithms enthusiast and want to add or improve an algorithm your contribution is welcome! Please be sure to checkout the Wiki for instructions.
- 🎥Articulation points/cut vertices (adjacency list) - O(V+E)
- Bellman-Ford (edge list, negative cycles, fast & optimized) - O(VE)
- 🎥Bellman-Ford (adjacency list, negative cycles) - O(VE)
- Bellman-Ford (adjacency matrix, negative cycles) - O(V3)
- 🎥Breadth first search (adjacency list) - O(V+E)
- Breadth first search (adjacency list, fast queue) - O(V+E)
- 🎥Bridges/cut edges (adjacency list) - O(V+E)
- Find connected components (adjacency list, union find) - O(Elog(E))
- Find connected components (adjacency list, DFS) - O(V+E)
- Depth first search (adjacency list, iterative) - O(V+E)
- Depth first search (adjacency list, iterative, fast stack) - O(V+E)
- 🎥Depth first search (adjacency list, recursive) - O(V+E)
- 🎥Dijkstra's shortest path (adjacency list, lazy implementation) - O(Elog(V))
- 🎥Dijkstra's shortest path (adjacency list, eager implementation + D-ary heap) - O(ElogE/V(V))
- 🎥Eulerian Path (directed edges) - O(E+V)
- 🎥Floyd Warshall algorithm (adjacency matrix, negative cycle check) - O(V3)
- Graph diameter (adjacency list) - O(VE)
- Kruskal's min spanning tree algorithm (edge list, union find) - O(Elog(E))
- 🎥Kruskal's min spanning tree algorithm (edge list, union find, lazy sorting) - O(Elog(E))
- 🎥Prim's min spanning tree algorithm (lazy version, adjacency list) - O(Elog(E))
- Prim's min spanning tree algorithm (lazy version, adjacency matrix) - O(V2)
- 🎥Prim's min spanning tree algorithm (eager version, adjacency list) - O(Elog(V))
- Steiner tree (minimum spanning tree generalization) - O(V3 + V2 * 2T + V * 3T)
- 🎥Tarjan's strongly connected components algorithm (adjacency list) - O(V+E)
- Tarjan's strongly connected components algorithm (adjacency matrix) - O(V2)
- 🎥Topological sort (acyclic graph, adjacency list) - O(V+E)
- Topological sort (acyclic graph, adjacency matrix) - O(V2)
- Traveling Salesman Problem (brute force) - O(n!)
- 🎥Traveling Salesman Problem (dynamic programming, iterative) - O(n22n)
- Traveling Salesman Problem (dynamic programming, recursive) - O(n22n)
This repository is released under the MIT license. In short, this means you are free to use this software in any personal, open-source or commercial projects. Attribution is optional but appreciated.