can someone tell me if i did this right?
if root initially points toCode: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); } }
what is the resulting tree after the following is executedCode:A B C D E F G
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?Code:A C B G F E D



LinkBack URL
About LinkBacks


