Assume a binary tree with integer values in the nodes. Design a linear-time algorithm that finds out existence of a path with a given sum. In other words, given a sum, you need to find a path from the root to any of the nodes that adds up to the given sum. Describe your algorithm in pseudocode. and Analyze its worst-case running time.

icon
Related questions
Question

Assume a binary tree with integer values in the nodes. Design a linear-time algorithm that finds out existence of a path with a given sum. In other words, given a sum, you need to find a path from the root to any of the nodes that adds up to the given sum.

Describe your algorithm in pseudocode. and Analyze its worst-case running time.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer