darwinrlo / public

0 stars 0 forks source link

Tree DFS #29

Open darwinrlo opened 4 years ago

darwinrlo commented 4 years ago

Sum of Path Numbers

Missteps

Areas of Improvement

darwinrlo commented 4 years ago

Path With Given Sequence

Observations

Missteps

Complexity

In the worst case, the binary tree is a linked list, the input sequence is as long as there are nodes, and it's a match. Since we're using recursion, a stack frame is allocated for each node. So the space complexity is O(n).

We may not visit every node, but in the worst case, we would visit every node, making the time complexity O(n).

Next Steps