Simple, straightforward Java solution
Simple and easy to understand Java solution.\n(Not the most efficient, due to the simple deserialization approach)\n\n\n    // since this is a binary search tre
Simple and easy to understand Java solution.\n(Not the most efficient, due to the simple deserialization approach)\n\n```\n    // since this is a binary search tree, we\'ll just output values in BFS\n    // order (when serializind), then add all values to the tree one by one (when deserializing)\n    // serialize will take O(n)\n    // deserialize will take O(n*h), where h is the height of the tree (n in the\n    // worst case, and log(n) if the tree is balanced)\n\n    // Encodes a tree to a single string.\n    public String serialize(TreeNode root) {\n        if (root == null) {\n            return null;\n        }\n        \n        StringBuilder sb = new StringBuilder();\n        Queue<TreeNode> q = new LinkedList<>();\n        q.add(root);\n        while (!q.isEmpty()) {\n            TreeNode n = q.remove();\n            sb.append(n.val).append(\',\');\n            if (n.left != null)\n                q.add(n.left);\n            if (n.right != null)\n                q.add(n.right);\n        }\n        sb.setLength(sb.length()-1); // remove last \',\'\n        return sb.toString();\n    }\n\n    // Decodes your encoded data to tree.\n    public TreeNode deserialize(String data) {\n        if (data == null) {\n            return null;\n        }\n        \n        String[] vals = data.split(",");\n        TreeNode root = new TreeNode(Integer.parseInt(vals[0]));\n        for (int i=1; i<vals.length; i++) {\n            add(root, Integer.parseInt(vals[i]));\n        }\n        return root;\n    }\n    \n    private static void add(TreeNode root, int val) {\n        TreeNode cur = root;\n        TreeNode parent = null;\n        while (cur != null) {\n            parent = cur;\n            cur = (val <= cur.val) ? cur.left : cur.right;\n        }\n        if (val <= parent.val) {\n            parent.left = new TreeNode(val);\n        } else {\n            parent.right = new TreeNode(val);\n        }\n    }\n\t```
['Breadth-First Search', 'Java']