1.
Breadth-First Search (BFS)
● Purpose: Traverses or searches tree/graph data structures.
● Time Complexity: O(V+E)O(V + E)O(V+E)
● Space Complexity: O(V)O(V)O(V)
● Use Cases: Finding the shortest path in unweighted graphs, level-order traversal of a
tree, solving puzzles like Rubik’s Cube.
● Remarks: Uses a queue data structure to manage the frontier.
2. Depth-First Search (DFS)
● Purpose: Traverses or searches tree/graph data structures.
● Time Complexity: O(V+E)O(V + E)O(V+E)
● Space Complexity: O(V)O(V)O(V) (with recursion, the call stack can go up to
O(V)O(V)O(V))
● Use Cases: Pathfinding, topological sorting, solving puzzles with backtracking, finding
connected components.
● Remarks: Can be implemented using a stack or recursively.
3. Dijkstra’s Algorithm
● Purpose: Finds the shortest path between nodes in a graph with non-negative edge
weights.
● Time Complexity: O(V2)O(V^2)O(V2) (with adjacency matrix), O((V+E)logV)O((V + E)
\log V)O((V+E)logV) (with adjacency list and min-heap)
● Space Complexity: O(V+E)O(V + E)O(V+E)
● Use Cases: GPS navigation systems, network routing protocols.
● Remarks: Cannot handle negative weight edges.
4. Bellman-Ford Algorithm
● Purpose: Finds the shortest path from a single source to all other vertices in a graph.
● Time Complexity: O(VE)O(VE)O(VE)
● Space Complexity: O(V)O(V)O(V)
● Use Cases: Finding shortest paths in graphs with negative weight edges, used in routing
protocols like RIP.
● Remarks: Can detect negative weight cycles.
5. Floyd-Warshall Algorithm
● Purpose: Finds shortest paths between all pairs of vertices.
● Time Complexity: O(V3)O(V^3)O(V3)
● Space Complexity: O(V2)O(V^2)O(V2)
● Use Cases: Network analysis, finding transitive closure of a graph.
● Remarks: Works with negative weights but no negative weight cycles.
6. Kruskal’s Algorithm
● Purpose: Finds the Minimum Spanning Tree (MST) of a graph.
● Time Complexity: O(ElogE)O(E \log E)O(ElogE)
● Space Complexity: O(V+E)O(V + E)O(V+E)
● Use Cases: Designing efficient network layouts, clustering analysis.
● Remarks: Uses union-find data structure to detect cycles.
7. Prim’s Algorithm
● Purpose: Finds the Minimum Spanning Tree (MST) of a graph.
● Time Complexity: O(V2)O(V^2)O(V2) (with adjacency matrix), O((V+E)logV)O((V + E)
\log V)O((V+E)logV) (with adjacency list and min-heap)
● Space Complexity: O(V)O(V)O(V)
● Use Cases: Network design, creating MSTs for geographic routing.
● Remarks: Starts with a single vertex and grows the MST one edge at a time.
8. A* Search Algorithm
● Purpose: Finds the shortest path between nodes in a weighted graph using heuristics.
● Time Complexity: O(E)O(E)O(E) (in the worst case)
● Space Complexity: O(V)O(V)O(V)
● Use Cases: Pathfinding in games, robot motion planning.
● Remarks: Uses heuristics to improve efficiency over Dijkstra’s algorithm.
9. Topological Sort
● Purpose: Linear ordering of vertices in a Directed Acyclic Graph (DAG).
● Time Complexity: O(V+E)O(V + E)O(V+E)
● Space Complexity: O(V)O(V)O(V)
● Use Cases: Task scheduling, resolving symbol dependencies in linkers.
● Remarks: Only applicable to DAGs.