Preorder Calculation

Time limit: 5000ms
Memory limit: 256mb

-------------------------Copy the following code, complete it and submit---------------------

/*
I, <Your Full Name>, am submitting the assignment for
an individual project.
I declare that the assignment here submitted is original except for
source material explicitly acknowledged, the piece of work, or a part
of the piece of work has not been submitted for more than one purpose
(i.e. to satisfy the requirements in two different courses) without
declaration. I also acknowledge that I am aware of University policy
and regulations on honesty in academic work, and of the disciplinary
guidelines and procedures applicable to breaches of such policy and
regulations, as contained in the University website
http://www.cuhk.edu.hk/policy/academichonesty/.
It is also understood that assignments without a properly signed
declaration by the student concerned will not be graded by the
teacher(s).
*/

#include <stdio.h>
#include <stdlib.h>

struct treeNode {
    int value;
    struct treeNode* left;
    struct treeNode* right;
};

typedef struct treeNode* TreeNode;


TreeNode CreateTreeNode(int value) {
    TreeNode node = (TreeNode) malloc(sizeof(struct treeNode));
    node->value = value;
    node->left = NULL;
    node->right = NULL;

    return node;
}

TreeNode BuildTree(int* inOrder, int* postOrder, int n) {
    // write your code here

}

void PreOrderPrint(TreeNode root) {
    if (root == NULL) {
        return;
    }

    printf("%d ", root->value);
    PreOrderPrint(root->left);
    PreOrderPrint(root->right);
}


int main() {
    int n, operation, value;
    scanf("%d", &n);

    int* inOrder = (int*) malloc(n * sizeof(int));
    int* postOrder = (int*) malloc(n * sizeof(int));

    for (int i=0;i<n;++i) {
        scanf("%d", inOrder + i);
    }

    for (int i=0;i<n;++i) {
        scanf("%d", postOrder + i);
    }

    TreeNode root = BuildTree(inOrder, postOrder, n);

    PreOrderPrint(root);
}


-----------------------------------------End of Code-----------------------------------------
Description:
Use in-order and post-order traversal sequence to build a binary tree.

Input:
The first line contains one integer N;
The second line contains N integers, which is the in-order traversal sequence;
The third line contains N integers, which is the post-order traversal sequence;

Output:
The pre-order traversal sequence

Sample Input 1:
10
1 2 3 4 5 6 7 8 9 10 
1 3 2 5 6 8 10 9 7 4

Sample Output 1:
4 2 1 3 7 6 5 9 8 10

Submit