0
votes

I want to find all path start with node a and end with node b.

Now my solution is that start from a to exec DFS and select path ends with b.

The complexity is O(egde + node), can it be optimized to O(path + node)?

Thanks!

1

1 Answers

0
votes

DFS has O(n), it means linear complexity, it cannot be improved in non-sorted graphs.