I'm implementing a generi method that's supposed to traverse a binary tree in PostOrder but when I attempt to use it, the Iterator doesn't work as It should when I attempt to use ot on a Binary Tree, can anyone spot my mistake in the code? Thanks.
The method makes use of a generic POIterator class which implements a generic Iterator<T>
here's th POIterator class
public class POIterator<T> implements Iterator<T>{
Deque<BNode<E>>someStack = new LinkedList<BNNode<E>>();
BNode<E> position;
public T next(){
position = position.pop();
if(!position.hasLeftNode())
return position.getInfo();
else{
position = position.getLeftNode();
somestack.push(position);}
next();//recurisive call
position = position.pop();
if(!position.hasRightNode())
next();//recursive call
}//end of next() method;
I have a getPOIterator method in some other class.
When I run tests to check my POIterator method, it doesn't work well/asits supposed to.
Can anyone find anything wrong wuth my POIterator code?