I am curious of knowing of an efficient algorithm for the problem:
Given two vertices s,t in a directed graph, is there a vertex x such that xs and xtare paths?
I can of course do a BFS from each node of the graph resulting in a quadratic time algorithm.
Or I can reverse all the edges of the graph, do a BFS from s store all reachable vertices in a hashtable, do a BFS from t and check for each reachable vertex if it is in the table, ifso, I found x. While the running time is linear, the extra space requirement is ugly.
Is there any elegant O(E + V) time algorithm for this problem?
xsis a path"? Do you mean that there is an edge $x \to s$? Do you mean that there exists a path that starts at $x$ and ends at $s$? 2. Your final question mentions only running time. Do you also have a space complexity requirement? If so, what is it exactly? Can you articulate your final question more precisely? Are you asking whether there is any algorithm a $O(V+E)$ running time and $o(V)$ space? Or what?