public void revTraversal(BinaryTree binaryTree)
{
Queue<Node> queue = new LinkedList<Node>();
Stack<Node> stack = new Stack<Node>();
Node temp;
queue.add(root);
while(!queue.isEmpty()){
temp = queue.poll();
if(temp.rightNode!=null)
queue.add(temp.rightNode);
if(temp.lefNode!=null)
queue.add(temp.lefNode);
stack.push(temp);
}
while(!stack.isEmpty())System.out.println("Nodes are"+ stack.pop().tData);
}
Why can't we simply iterate the Binary with right child before left child and pushh all those values in stack directly. Why we using a queue as backing datastructure ?