Given a Binary Tree of size N, you need to find all the possible paths from root node to all the leaf node's of the binary tree.
Input: 1 / \ 2 3 Output: 1 2 #1 3 # Explanation: All possible paths: 1->2 1->3
Input: 10 / \ 20 30 / \ 40 60 Output: 10 20 40 #10 20 60 #10 30 #
Your task is to complete the function Paths() that takes the root node as an argument and return all the possible path. (All the path are printed '#' separated by the driver's code.)
Note: The return type
python: list of list
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(H).
Note: H is the height of the tree.
Note: The Input/Ouput format and Example given, are used for the system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from the stdin/console. The task is to complete the function specified, and not to write the full code.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.