Data Structures & AlgorithmsHardICPC regional · Product Company SDE
Problem: What is the time complexity of the Floyd-Warshall algorithm for finding shortest paths between every pair of nodes in a graph with V vertices?
- A. O(V E log V)
- B. O(V^3)
- C. O(V^2)
- D. O(V log V)
Correct answer: B. O(V^3)
Floyd-Warshall tries every intermediate vertex k for every pair (i,j), giving three nested loops over V vertices: O(V^3).
More Coding Interview Problems questions
- Problem: Which of these best describes why Kruskal's MST algorithm needs a Union-Find (disjoint set) structure?
- Problem: Between Kruskal's and Prim's MST algorithms, which is typically preferred for a dense graph represented with an adjacency matrix?
- Problem: Which statement correctly contrasts 0/1 knapsack and fractional knapsack?
- Problem: Activity selection (pick the maximum number of non-overlapping intervals from a set) is solved optimally by which greedy strategy?
- Problem: Which of these coin systems is a classic counterexample where the greedy 'always take the largest coin' algorithm fails to find…
- Problem: Huffman coding builds an optimal prefix-free binary code for a set of symbol frequencies. Which greedy step does it repeat?