binary tree preorder traversal
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
/**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
int* preorderTraversal(struct TreeNode* root, int* returnSize) {
int i = 0;
//int *arr = (int *)malloc(100*sizeof(int));
if(root)
{
returnSize[iPP] = root->val;
preorderTraversal(root->left, returnSize);
preorderTraversal(root->right, returnSize);
}
return returnSize;
}