can someone tell me if i did this right?
Code:
void TraversePreOrder(TreeNode *root, apstack<char> &s){
if(root!=0){
s.push(root->info);
TraversePreOrder(root->left, s);
TraversePreOrder(root->right, s);
}
}
void TraversePostOrder(TreeNode *root, apstack<char> &s){
if(root!=0){
TraversePostOrder(root->left, s);
TraversePostOrder(root->right, s);
s.pop(root->info);
}
}
if root initially points to
what is the resulting tree after the following is executed
apstack<char> stack;
TraversePreOrder(root,stack);
TraversePostOrder(root,stack);
after the the first function the stack would contain GFCEDBA, with g at the top, right?
after the second function, the tree would be:
am i correct?