CS2004_Graph_Traversal_Flashcards
(10 cards)
What is Depth-First Search (DFS)?
DFS is a graph traversal algorithm that explores as far as possible along each branch before backtracking.
✅ Uses a stack (or recursion) to track the path.
What is Breadth-First Search (BFS)?
BFS is a graph traversal algorithm that explores all neighbours of a node before moving to the next level.
✅ Uses a queue to maintain the order of exploration.
What is the time complexity of BFS and DFS?
Both BFS and DFS run in O(V + E), where V is the number of vertices and E is the number of edges.
What is Dijkstra’s Algorithm used for?
Dijkstra’s algorithm finds the shortest path from a starting node to all other nodes in a weighted graph with non-negative edge weights.
How does Dijkstra’s algorithm work?
It uses a priority queue to explore the lowest-cost node first and updates distances to neighbours based on cumulative cost.
What is A* search?
A* is a pathfinding algorithm that uses both actual cost from the start and estimated cost to the goal (via a heuristic).
What is the key difference between A* and Dijkstra’s Algorithm?
A* uses a heuristic to guide the search, making it more efficient for goal-directed searches.
✅ Dijkstra is uninformed; A* is informed.
What is a Minimum Spanning Tree (MST)?
An MST is a subset of edges in a connected, weighted graph that connects all vertices with the minimum total edge weight and no cycles.
What is Prim’s Algorithm?
Prim’s algorithm builds the MST by starting from one node and repeatedly adding the smallest edge connecting the tree to a new node.
What is Kruskal’s Algorithm?
Kruskal’s algorithm builds the MST by sorting all edges by weight and adding them one by one, avoiding cycles using disjoint sets.