Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct node* buildTree(char in[], char pre[], int inStrt, int inEnd)
- {
- static int preIndex =(sizeof(pre)/sizeof(pre[0]))-1; //zadnji u postorderu je korjen
- if(inStrt > inEnd)
- {
- return NULL;}
- struct node *tNode = newNode(pre[preIndex--]); //krecem se od iza zbog defiicje postordera
- if(inStrt == inEnd) //tu nam je bazicni slucaj
- return tNode;
- int inIndex = search(in, inStrt, inEnd, tNode->data);
- tNode->left= buildTree(in, pre, inStrt, inIndex-1);
- tNode->right = buildTree(in, pre, inIndex+1, inEnd);
- return tNode;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement