Last active
August 10, 2021 22:48
-
-
Save VXU1230/ffbf69992ab21a6f2712f3329c3b18a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, val=None): | |
self.val = val | |
self.left = None | |
self.right = None | |
def get_root(): | |
values = iter([1, 6, 4, 7, None, None, 9, 8, None, None, | |
10, None, None, 5, None, None, 2, 3, None, None, 11, None, None]) | |
def tree_recur(itr): | |
val = next(itr) | |
if val is not None: | |
node = Node(val) | |
node.left = tree_recur(itr) | |
node.right = tree_recur(itr) | |
return node | |
return tree_recur(values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment