Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int i=0;
- struct Node *constructTree(int n, int pre[], char preLN[])
- {
- if(i>=n) return NULL;
- struct Node *root=new Node(pre[i]);
- if(preLN[i]=='L') return root;
- i++;
- root->left=constructTree(n,pre,preLN);
- i++;
- root->right=constructTree(n,pre,preLN);
- return root;
- }
Advertisement
Add Comment
Please, Sign In to add comment