Q:

PostOrder Traversal Java

I am trying to return a string representation of my tree after a post order traversal but it is giving me the works. Seems like a simple enough code but I can't seem to get it. Debugging isn't of much help either. I lose track of what I'm supposed to be looking at. What is going wrong here? 
I know using a string in this sense is bad practice but I was just throwing something together. I could have used a string buffer or something else but now I'm stumped as to why this is not working and would like to figure out the reason. 
  public String postOrderTraversal(){
        String answer = "";
        return postOrderTraversal(root, answer);
    }

    private String postOrderTraversal(Node aux, String answer){
        if(aux == null){
            return "";
        }
        else{
            postOrderTraversal(aux.left, answer);
            postOrderTraversal(aux.right, answer);
            answer += aux.data;
        }

        return answer;

    }

A:

You are not adding the post-order traversals of the subtrees. You can correct it as
private String postOrderTraversal(Node aux) {
    if(aux == null) return "";
    return postOrderTraversal(aux.left) + postOrderTraversal(aux.right) + aux.data;
}

