Question: Problem Statement You want to walk in a forest but you can only walk the paths where the sum is your lucky number ( given

Problem Statement
You want to walk in a forest but you can only walk the paths where the sum is your lucky
number (given). You start at a fixed point forming a tree of paths. Dont worry atleast one valid
path will always be there.
Eg:
If the tree is 5,4,8,11,null,9,4,-7,2,null,null,5,1 which becomes
Here if your lucky number was 22 you can find three paths (paths have to be from root to
leaf only):
5,4,11,2;5,8,9;5,8,4,5
Another example:
Input: 1,4,3,null,null,-10,null,10,2::5
Tree:
lucky number: 5
Paths: 1,4;1,3,-10,11
Another example:
Input: 1,2,3,4,5,null,-4,1::0
Tree:
lucky number: 0
Paths: 1,3,-4
Requirements
1. Implement the above problem statement as a DFS.
2. Analyze the time complexity of your algorithm.
3. Implement the above problem statement using Python 3.7.
4. Make sure proper exception handling is written for the code.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!