public String serializeLevelOrder(Node root) {
        if (root == null) {
            return "";
        }

        Deque<Node> queue = new LinkedList<>();
        queue.offerFirst(root);
        StringBuffer buff = new StringBuffer();
        while (!queue.isEmpty()) {
            root = queue.pollFirst();
            if (root == null) {
                buff.append("%,");
            } else {
                buff.append(root.data).append(",");
                queue.offer(root.left);
                queue.offer(root.right);
            }
        }
        for (int i = buff.length() - 1; i >= 0; i--) {
            if (buff.charAt(i) == '%' || buff.charAt(i) == ',') {
                buff.deleteCharAt(i);
            } else {
                break;
            }
        }
        return buff.toString();
    }
Serialize tree using level order traversal.
src/com/interview/tree/SerializeDeserializeBinaryTree.java