Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- binary_tree = { "value" : 1, "left":
- {
- "value": 7, "left": None, "right":
- {
- "value": 1, "left":
- {
- "value": 5, "left": None, "right": None
- }, "right":
- {
- "value":121, "left": None, "right": None
- },
- },
- }, "right":
- {
- "value": 5, "left": None, "right": None
- }
- }
- def check_node_cond(tree, f):
- if tree == None:
- return False
- ok = f(tree['value'])
- ok = ok or check_node_cond(tree["left"], f)
- ok = ok or check_node_cond(tree["right"], f)
- return ok
- print(check_node_cond(binary_tree, lambda x: x % 2 == 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement