Question
Given a directed graph G = (V, E) and two nodes s, t, an st-walk is a sequence of nodes s = v0, v1, .
Given a directed graph G = (V, E) and two nodes s, t, an st-walk is a sequence of nodes s = v0, v1, . . . , vk = t where (vi , vi+1) is an edge of G for 0 i < k. Note that a node may be visited multiple times in a walk ? this is how it differs from a path. Given G, s, t and an integer k n, design a linear time algorithm to check if there is an st-walk in G that visits at least k distinct nodes including s and t.
Solve the problem when G is a DAG.
Let s v1, s v2, . . . , s v` be all outgoing edges of s. Describe a recursive solution for this problem.
Modify DFS to solve this problem on a DAG.
Hint: it is easier to think about this problem if you view the vertices in topological order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started