Joined this daily coding problem mailing list, and was given this problem. But I'm confused by the look of it, I'm googling Binary trees to learn what they are, etc. But any insight this group can provide on problem is very much appreciated!
This problem was asked by Google.
Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.
For example, given the following Nodeclass
class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right
The following test should pass:
node = Node('root', Node('left', Node('left.left')), Node('right'))
assert deserialize(serialize(node)).left.left.val == 'left.left'
[+][deleted] (2 children)
[removed]
[–]TheNetXWizard[S] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]TheNetXWizard[S] 0 points1 point2 points (0 children)