Data Structures & AlgorithmsVery hardICPC regional · graph theory
Problem: Which problem asks for the length of the shortest cycle in an undirected unweighted graph?
- A. Kruskal's algorithm
- B. Gale-Shapley
- C. Bellman-Ford
- D. BFS from every vertex, tracking the first non-tree edge
Correct answer: D. BFS from every vertex, tracking the first non-tree edge
BFS from each vertex detects non-tree edges that close the shortest cycles through it.
More Coding Interview Problems questions
- Problem: Which theorem guarantees a perfect matching in a bipartite graph when Hall's condition holds for the smaller side?
- Problem: What is the main idea of the 'parallel binary search' technique?
- Problem: Which structure gives fast membership tests of substrings after O(n) construction (for a fixed alphabet)?
- Problem: What is the expected number of rounds of a randomised min-cut (Karger's algorithm) needed for a graph with n vertices to find a…
- Problem: What does the term 'amortised analysis' mean?
- Problem: What is the complexity of computing the number of inversions using a Fenwick tree over n distinct values?