Using Preorder traversal
\nclass Codec:\n\n    def serialize(self, root: TreeNode) -> str:\n        res = []\n        \n        def dfs(root):\n            if not root:\n               
```\nclass Codec:\n\n    def serialize(self, root: TreeNode) -> str:\n        res = []\n        \n        def dfs(root):\n            if not root:\n                res.append(\'N\')\n                return\n            \n            res.append(str(root.val))\n            dfs(root.left)\n            dfs(root.right)\n        \n        dfs(root)\n        return \',\'.join(res)\n        \n\n    def deserialize(self, data: str) -> TreeNode:\n        vals = data.split(\',\')\n        self.i = 0\n        \n        def dfs():\n            if vals[self.i] == \'N\':\n                self.i += 1\n                return None\n            \n            node = TreeNode(int(vals[self.i]))\n            self.i += 1\n            node.left = dfs()\n            node.right = dfs()\n            \n            return node\n        \n        return dfs()\n```
['Depth-First Search', 'Python']