Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arbore_binar_cautare = { "value" : 4, "left":
- {"value": 2, "left": {"value": 1, "left": None, "right": None}, "right": {"value": 3, "left": None, "right": None},
- }, "right":
- {"value": 7, "left": None, "right": None}
- }
- def isBinSrcTree(tree):
- def utilIsBinSrcTree(tree):
- ok = True
- if tree['left'] is not None:
- ok &= tree['value'] > utilIsBinSrcTree(tree['left'])[1]
- if tree['right'] is not None:
- ok &= tree['value'] < utilIsBinSrcTree(tree['right'])[1]
- return ok, tree['value']
- return utilIsBinSrcTree(tree)[0]
- print(isBinSrcTree(arbore_binar_cautare))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement