Sanath12345

Untitled

Sep 15th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. int i=0;
  2. struct Node *constructTree(int n, int pre[], char preLN[])
  3. {
  4. if(i>=n) return NULL;
  5. struct Node *root=new Node(pre[i]);
  6. if(preLN[i]=='L') return root;
  7. i++;
  8. root->left=constructTree(n,pre,preLN);
  9. i++;
  10. root->right=constructTree(n,pre,preLN);
  11. return root;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment