ЁЯУв Too many exams? DonтАЩt know which one suits you best? Book Your Free Expert ЁЯСЙ call Now!


    Question

    You are given a problem to find the shortest path in a

    graph where edge weights can be negative. Which algorithm would you *not* use?
    A Bellman-Ford Correct Answer Incorrect Answer
    B Floyd-Warshall Correct Answer Incorrect Answer
    C Dijkstra's Algorithm Correct Answer Incorrect Answer
    D SPFA (Shortest Path Faster Algorithm) Correct Answer Incorrect Answer
    E A* Search (with appropriate heuristic) Correct Answer Incorrect Answer

    Solution

    Dijkstra's Algorithm works correctly only for graphs with non-negative edge weights. If negative edge weights are present, it may produce incorrect results. Bellman-Ford, Floyd-Warshall, and SPFA are designed to handle negative edge weights (Bellman-Ford also detects negative cycles). A* search can also work with negative weights if the heuristic is consistent.

    Practice Next
    More IT Operating System Questions
    ask-question