Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = {'value': 4, 'left': {'value': 2, 'left': {'value': 1, 'left': None, 'right': None},
- 'right': {'value': 3, 'left': None, 'right': None}},
- 'right': {'value': 7, 'left': {'value': 5, 'left': None, 'right': None}, 'right': None}}
- def src_in_bin_src_tree(tree, x):
- if tree is None:
- return False
- if tree['value'] == x:
- return True
- if x < tree['value']:
- return src_in_bin_src_tree(tree['left'], x)
- else:
- return src_in_bin_src_tree(tree['right'], x)
- print(src_in_bin_src_tree(t, 5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement