private String serializeInner(BinaryNode root) {
    StringBuilder stringBuilder = new StringBuilder();
    if (root == null) {
      stringBuilder.append("#");
    } else {
      stringBuilder.append(root.getData());
      stringBuilder.append(serializeInner(root.getLeft()));
      stringBuilder.append(serializeInner(root.getRight()));
    }
    return stringBuilder.toString();
  }
Recursive algorithm based on a pre order traversal of the tree to generate an string with the
content of the tree and # for every leaf. The complexity order of this algorithm is O(N) where
N is the number of nodes in the tree.
src/main/java/com/github/pedrovgs/problem46/BinaryTreeSerialization.java