the compiler compile the code,but traversing output is wrong .please chech ny logic is correct,tell me best tutorial to learn of binary tree using stack .

void usman:: inorder()
{
stack<node*>s;   
    node *t=root;
    while(!s.empty()||t!=NULL)
    {
   if(t!=NULL)
   {
    s.push(t);
    t=t->left;
}
else
{   
   t=s.top();
  s.pop();
    cout<<t->data<<",";
    t=t->right;
}
   }
    }
struct treenode
{struct treenode *llink;
int data;
struct treenode *rlink;
};
typedef struct treenode TREE;
void inorder(TREE *rt)
{if(rt!=NULL)
{inorder(rt->llink);
cout<<endl<<rt->data;
inorder(rt->rlink);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.