VibraXX
Live Quiz Arena
🎁 1 Free Round Daily
⚡ Enter Arena
HomeCategoriesLogic & PuzzlesQuestion
Question
Logic & Puzzles

If a programmer uses dynamic programming to solve the all-pairs shortest path problem for a directed graph, what memory scaling behavior occurs relative to the number of vertices?

A)Linear scaling, O(V)
B)Logarithmic scaling, O(log V)
C)Quadratic scaling, O(V^2)
D)Exponential scaling, O(2^V)

💡 Explanation

The Floyd-Warshall algorithm, a dynamic programming approach for the all-pairs shortest path, stores a distance matrix. Because the matrix requires space for each pair of vertices, the memory scales quadratically, O(V^2); therefore quadratic scaling is correct, rather than linear, logarithmic, or exponential scaling.

🏆 Up to £1,000 monthly prize pool

Ready for the live challenge? Join the next global round now.
*Terms apply. Skill-based competition.

⚡ Enter Arena

Related Questions

Browse Logic & Puzzles