Very simple Python solution using 2 approaches - preorder postorder
\n# Definition for a binary tree node.\n# class TreeNode(object):\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         s
```\n# Definition for a binary tree node.\n# class TreeNode(object):\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.right = None\n\nclass Codec:\n\n    # Logic: Serialize the tree into pre-order traversal and store it as a string. Deserialize this pre order traversal by popping out the first item from this string.\n    \n    def serialize(self, root):\n        """Encodes a tree to a single string.\n        \n        :type root: TreeNode\n        :rtype: str\n        """\n        res = []\n        def preorder(node):\n            if not node:\n                return\n            res.append(str(node.val))\n            preorder(node.left)\n            preorder(node.right)  \n            \n        preorder(root)\n        return " ".join(res)\n        \n\n    def deserialize(self, data):\n        """Decodes your encoded data to tree.\n        \n        :type data: str\n        :rtype: TreeNode\n        """\n        def read_from_preorder_array(queue, low, high):\n            if not queue:\n                return None\n            if low < int(queue[0]) < high:\n                node = TreeNode(int(queue.popleft()))                \n                node.left = read_from_preorder_array(queue, low, node.val)\n                node.right = read_from_preorder_array(queue, node.val, high)\n                return node\n            else:\n                return None\n        \n        if not data:\n            return None\n        queue = collections.deque(data.split(" "))\n        return read_from_preorder_array(queue, -sys.maxint, sys.maxint)\n        \n\n# Your Codec object will be instantiated and called as such:\n# codec = Codec()\n# codec.deserialize(codec.serialize(root))\n\n\n# Definition for a binary tree node.\n# class TreeNode(object):\n#     def __init__(self, x):\n#         self.val = x\n#         self.left = None\n#         self.right = None\n\nclass Codec:\n    # Logic: Serialize the tree into post-order traversal and store it as a string. Deserialize this post order traversal by popping out the last item from this string.\n    \n    def serialize(self, root):\n        """Encodes a tree to a single string.\n        \n        :type root: TreeNode\n        :rtype: str\n        """\n        res = []\n        def postorder_traversal(node):\n            if not node:\n                return\n            postorder_traversal(node.left)\n            postorder_traversal(node.right)\n            res.append(str(node.val))\n        \n        postorder_traversal(root)\n        # print res\n        return " ".join(res)\n        \n\n    def deserialize(self, data):\n        """Decodes your encoded data to tree.\n        \n        :type data: str\n        :rtype: TreeNode\n        """\n        def construct_tree_from_post_order(res, low, high):\n            if not res:\n                return None\n            if low < int(res[-1]) < high:\n                val = int(res.pop())\n                node = TreeNode(val)\n                node.right = construct_tree_from_post_order(res, val, high)\n                node.left = construct_tree_from_post_order(res, low, val)\n                return node\n            else:\n                return None\n        \n        if not data:\n            return None\n        res = data.split(" ")\n        return construct_tree_from_post_order(res, -sys.maxint, sys.maxint)\n            \n\n# Your Codec object will be instantiated and called as such:\n# codec = Codec()\n# codec.deserialize(codec.serialize(root))\n```
[]