Well, your reverseTreeStack method can give you a StackOverflowError if your tree is too large, so using a loop instead of recursion might be a better choice (unless you know that your trees will never be that big).
Also, why are you “deleting” each node? ( node = null actually just removes the link that you have in this method exactly ...) Usually just forgetting that root ( root = null ) will delete your tree if you structure it in the classic Node way (parent, leftChild, rightChild ) and do not store pointers to nodes anywhere else.
source share