Challenge your knowledge of core graph data structures and advanced algorithms with these thought-provoking questions designed for experienced learners.
Adjacency Matrix vs. List Efficiency
Given a sparse undirected graph with 10,000 vertices and 15,000 edges, which representation consumes less space and offers faster iteration over neighbors of a vertex?
- Adjacency Matrix is more space-efficient but slower for neighbor queries.
- Adjacency Matrix is better in both space and iteration speed.
- Adjacency List is always slower than the Adjacency Matrix.
- Adjacency List provides less space usage and faster neighbor iteration.
- Adjacency Matrix and Adjacency List use equivalent space.
BFS Level Order Traversal
If you perform a Breadth-First Search (BFS) traversal starting from node A in an unweighted graph, what property holds for the nodes first discovered at each level?
- They are at equal minimal path distance from A.
- They are visited in strictly decreasing order of degree.
- They always form a cycle with A.
- They are on the same connected component only if the graph is directed.
- They are visited in topological order.
DFS Application - Cycle Detection
In a directed graph, how can Depth-First Search (DFS) be used to detect cycles, and what must be tracked for correct detection?
- Apply BFS instead for cycle detection.
- Track only the visited nodes globally.
- Monitor successors in a queue to find cycles.
- Track the recursion stack to detect a back edge during DFS.
- Use only degree counts to identify cycles.
Topological Sort Prerequisites
Which property must hold true for a directed graph in order for a topological ordering to exist, for example in task scheduling scenarios?
- The graph must be Eulerian.
- The graph must be connected and undirected.
- The graph must be weighted with nonnegative edges.
- The graph must be acyclic with all edges directed.
- All vertices must have an out-degree at least 2.
Dijkstra's Limitation with Negative Weights
Why is Dijkstra's shortest path algorithm incorrect on graphs containing negative edge weights, even if no negative cycles exist?
- Because it ignores edge directions entirely.
- Because it creates cycles when updating node distances.
- Because it always works with negative weights.
- Because it must visit all nodes before producing any output.
- Because it assumes once a node's shortest path is found, it cannot be improved later.
Bellman-Ford Algorithm Output
Given a directed graph with 'n' vertices and possible negative edge weights but no negative cycles, what does the Bellman-Ford algorithm guarantee after (n-1) relaxations?
- Correct shortest path distances from the source to all other vertices.
- An Eulerian path, if one exists.
- The longest paths from the source to all vertices.
- A minimum spanning tree of the graph.
- A valid topological sort of the vertices.
Floyd-Warshall's Core Principle
Which principle does Floyd-Warshall's all-pairs shortest path algorithm use to incrementally build solutions, as demonstrated when updating distance(i, j) via possible intermediate vertices?
- Divide and conquer splitting the graph in half.
- Dynamic programming with repeated state updates using intermediate nodes.
- Heap-based edge selection for every update.
- Backtracking on all possible path combinations.
- Greedy selection of minimum weight edges iteratively.
Kruskal's Edge Selection Sequence
When applying Kruskal's algorithm to construct a Minimum Spanning Tree for a weighted undirected graph, which of the following steps ensures a valid solution?
- Use BFS to add edges in level order.
- Select the highest-weight edge first and recurse.
- Add any random edge until all vertices are included.
- Sort all edges by increasing weight and add them if they don't create a cycle.
- Sort vertices by degree, then add their lowest edge.
Prim's Algorithm Priority Structure
When running Prim's algorithm to grow a Minimum Spanning Tree from a starting vertex, which data structure most efficiently tracks and updates the nearest neighbors to the growing tree?
- A binary min-heap or priority queue maintaining candidate edges.
- A hash table keyed by vertex degree.
- A stack to allow backtracking from leaves.
- A simple array of visited flags only.
- A recursion stack used for DFS cleaning.
Comparing Adjacency Representation Operations
Which operation is typically faster using an adjacency matrix than an adjacency list for a graph with 'n' vertices and 'e' edges?
- Listing all neighbors of a vertex.
- Checking the existence of an edge between two given vertices.
- Iterating over all outgoing edges efficiently.
- Finding the degree of every vertex.
- Reducing space for sparse graphs.