This is a pretty silly question unless the graph is quite simple or small (because the output size is generally exponential wrt the input) and acyclic (when there are infinitely many paths). If I were interviewing someone, I'd like to have them tell me this before starting to describe an algorithm.
Anyway, an exhaustive DFS that backtracks whenever it finds a cycle (encounters a node already on the stack) and prints the stack whenever it finds the destination will do the job, though it won't enumerate paths with cycles in them. On Nov 20, 5:22 pm, SAMMM <somnath.nit...@gmail.com> wrote: > Given a (Directed/Non Directed) graph and a source node and > destination node . Now your task is to find all the paths from a > source node to the destination node . Both for directed and non > directed graph. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.