C++ | Simple and Intuitive | 99% | Easy to Understand
\nclass Codec {\npublic:\n    void encode(TreeNode* root, string &str){\n        if(root == NULL)\n            return;\n        str += to_string(root->val);\n  
```\nclass Codec {\npublic:\n    void encode(TreeNode* root, string &str){\n        if(root == NULL)\n            return;\n        str += to_string(root->val);\n        str += "-";\n        encode(root->left, str);\n        encode(root->right, str);\n    }\n\n    // Encodes a tree to a single string.\n    string serialize(TreeNode* root) {\n        string str = "";\n        encode(root, str);\n        return str;\n    }\n\n    // Decodes your encoded data to tree.\n    TreeNode* deserialize(string data) {\n        TreeNode* root = NULL;\n        stringstream ss(data);\n        string value;\n        while(getline(ss, value, \'-\')){\n            root = insert(root, stoi(value));\n        }\n        return root;\n    }\n    \n    TreeNode* insert(TreeNode* root, int data){\n        if(root == NULL){\n            root = new TreeNode(data);\n            return root;\n        }\n        if(root->val > data){\n            root->left = insert(root->left, data);\n            return root;\n        }\n        else{\n            root->right = insert(root->right, data);\n            return root;\n        }\n    }\n};\n\n```
['Binary Search Tree', 'C', 'C++']