Java simple preorder solution
\npublic class Codec {\n\n    // Encodes a tree to a single string.\n    public void preorder(TreeNode root, StringBuilder sb) {\n        if (root == null) {\n 
```\npublic class Codec {\n\n    // Encodes a tree to a single string.\n    public void preorder(TreeNode root, StringBuilder sb) {\n        if (root == null) {\n            sb.append("n" + "/");\n            return;\n        }\n        sb.append(root.val + "/");\n        preorder(root.left, sb);\n        preorder(root.right, sb);\n    }\n\n    public String serialize(TreeNode root) {\n        StringBuilder sb = new StringBuilder("");\n        preorder(root, sb);\n        return sb.toString();\n    }\n\n    // Decodes your encoded data to tree.\n    public TreeNode constructTree(String preorder[], int index[], int end) {\n        if (index[0] > end) return null;\n        if (preorder[index[0]].equals("n")) {\n            index[0] += 1;\n            return null;\n        }\n        TreeNode root = new TreeNode(Integer.parseInt(preorder[index[0]]));\n        index[0] += 1;\n        root.left = constructTree(preorder, index, end);\n        root.right = constructTree(preorder, index, end);\n        return root;\n    }\n\n    public TreeNode deserialize(String data) {\n        String preorder[] = data.split("/");\n        TreeNode root = constructTree(preorder, new int[1], preorder.length - 1);\n        return root;\n    }\n}\n```
['Depth-First Search', 'Binary Search Tree', 'Java']