Data Structures & AlgorithmsHardICPC regional · geometry MST
Problem: Which algorithm solves the 'minimum cost to connect all points' in the Euclidean plane with n points in O(n^2) time (dense graph)?
- A. Bellman-Ford
- B. Kosaraju's algorithm
- C. Hungarian algorithm
- D. Prim's algorithm on the complete graph
Correct answer: D. Prim's algorithm on the complete graph
Prim's O(V^2) variant is ideal for dense complete graphs such as the one on n points.
More Coding Interview Problems questions
- Problem: What is the time complexity of building a trie for n strings of total length L?
- Problem: What is a 'bridge' in an undirected graph?
- Problem: Which algorithm finds the strongly connected components of a directed graph using a single DFS with a stack?
- Problem: What is the maximum number of edges in a bipartite graph on n vertices with sides of size n/2?
- Problem: Which problem is solved by Dijkstra's algorithm on a graph whose edge weights are small integers, using buckets (Dial's algorithm)?
- Problem: What is the best known approach for range-mode queries on a static array?