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

  • google app store apple app store
  • ✖

      Question

      Consider a directed acyclic graph (DAG). The problem of

      finding the longest path in a DAG (with edge weights) can be solved in:
      A Polynomial time via dynamic programming after topological sort Correct Answer Incorrect Answer
      B Is NP-hard in DAGs Correct Answer Incorrect Answer
      C Requires exponential time Correct Answer Incorrect Answer
      D Solvable only for unweighted DAGs Correct Answer Incorrect Answer
      E Equivalent to shortest path with Dijkstra Correct Answer Incorrect Answer

      Solution

      Longest path in general graphs is NP-hard, but in DAGs it's solvable by topological order relaxation (O(V+E)).

      Practice Next
      ask-question