Rebuild Binary Tree from Preorder and Inorder Traversal
Question:
struct NODE {
NODE* pLeft;
NODE* pRight;
char chValue;
};
e.g.
preorder traversal : a b d c e f
inorder traversal : d b a e c f
Answer:
#include
using namespace std;
struct NODE {
NODE* pLeft;
NODE* pRight;
char chValue;
};
void PrintPreOrder(NODE* pRoot) {
if (!pRoot)
return;
cout << pRoot->chValue;