Problem 3.5: Bigger Path (100 pts)
Now, implement bigger_path
, which removes the restriction that paths must begin at the root -- they can begin at any node. You can use bigpath
to help your implementation.
def bigger_path(t, n):
"""Return the number of paths in t that have a sum larger or equal to n.
>>> t = tree(1, [tree(2), tree(3, [tree(4), tree(5)])])
>>> bigger_path(t, 3)
9
>>> bigger_path(t, 6)
4
>>> bigger_path(t, 9)
1
"""
"*** YOUR CODE HERE ***"