0

im trying to store preorder tree transversal into a stack though am getting a wide array of errors: to many arguments in void print_order, to many arguments in void preorder, and push has not been declared. any help please!

void print_inorder(BST *& p, stack <int> *& s);
void printOutText(BST *& p)
{
     ofstream myfile;
     myfile.open ("example.txt");     
     stack <int> s;
     
     preorder(p, s);
     
     myfile.close();
     

}

void preorder(BST *& p, stack <int> *& s)
{       
     if (p != NULL) 
     {
        s.push(p->data);
        preorder(p->left);  // print left subtree
        preorder(p->right); // print right subtree
     }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by daviddoria
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.