Post order help

Here is my code for traversals. I have preorder and inorder working. However, I can't get my postorder to print out more than the first digit. Any help will be much appreciated.


// * * * * Traversal begins * * * * //
cout << "The tree traversed INORDER is" << "\n";
p = root;

do
{
while (p != nil)
{
ptrstack.push(*p);
p = (*p).left;
}

if (!(ptrstack.empty_stack()))
{
ptrstack.pop(numb);
p = numb.right;
cout << (numb).info << "\n";
}

}while ((p != nil) || (!(ptrstack.empty_stack())));

cout << "The tree traversed PREORDER is" << "\n";
p = root;

do
{
while (p != nil)
{
ptrstack.push(*p);
p = (*p).right;
}

if (!(ptrstack.empty_stack()))
{
ptrstack.pop(numb);
p = numb.left;
cout << (numb).info << "\n";
}

}while ((p != nil) || (!(ptrstack.empty_stack())));



cout << "The tree traversed POSTORDER is" << "\n";
p = root;

do
{
while (p != nil)
{
ptrstack.push(*p);
p = (*p).left;
}

if (!(ptrstack.empty_stack()))
{
ptrstack.pop(numb);
p = numb.left;
cout << (numb).info << "\n";
}

}while ((p != nil) || (!(ptrstack.empty_stack())));
Topic archived. No new replies allowed.