Home » 
        MCQs » 
        Algorithms MCQs
    
        
    Why is the Floyd-Warshall algorithm better suited for dense graphs rather than sparse graphs?
    
    
        
    31. Why is the Floyd-Warshall algorithm better suited for dense graphs rather than sparse graphs?
    
      - It has a lower time complexity for dense graphs.
 
      - It runs in constant time for dense graphs.
 
      - It ignores the number of edges in the graph.
 
      - It performs the same regardless of graph density.
 
    
    Answer
    The correct answer is: C) It ignores the number of edges in the graph.
    Explanation
    The Floyd-Warshall algorithm runs in O(V^3) time regardless of the number of edges.