📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    What is a key characteristic regarding negative edge

    weights in the Floyd-Warshall algorithm?
    A It cannot handle any negative edge weights. Correct Answer Incorrect Answer
    B It can handle negative edge weights, but not negative cycles. Correct Answer Incorrect Answer
    C It can handle negative cycles, but not negative edge weights. Correct Answer Incorrect Answer
    D It only works with graphs where all edge weights are positive. Correct Answer Incorrect Answer
    E It requires all edge weights to be integers. Correct Answer Incorrect Answer

    Solution

    The Floyd-Warshall algorithm is capable of handling graphs with negative edge weights. However, it cannot correctly compute shortest paths if the graph contains any negative weight cycles. The presence of a negative cycle would mean that paths could become arbitrarily short (negative infinity) by repeatedly traversing the cycle. The algorithm can, however, be used to detect the presence of negative cycles.

    Practice Next
    ask-question