Why doesn't your tree code have an insert function? It's almost impossible to trace what you've done.
I didn't know how to wite it.
But the problem is with preTraverse().I don't know what is proformed when preTraverse() is run with a null parameter.
The question was about a complete binary tree whose preorder traversal is
'SBDHXEJKTFG'
I wanted to test my solution
Last edited on
Would you please draw the proposed tree?
I correct my problem.Now my question is that the inorder traversal of the right subtree of root is the same as its preorder traversal.Why is that?
And the subtree is not a riht linear subtree.See the snippet:
1 2 3 4 5 6 7 8 9
|
temp = &root;
temp = temp->RChild = new Node;
temp->data = 'T';
temp->RChild = new Node;
temp->RChild->data = 'G';
temp->LChild = new Node;
temp->LChild->data = 'F';
|
Last edited on
You're right, pre, in and post order traversals do produce different sequences.
corrected the problem.Thank you