mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
18 lines
434 B
C
18 lines
434 B
C
void processTraversal(struct TreeNode *root, int *res, int *size)
|
|
{
|
|
if (!root)
|
|
return;
|
|
processTraversal(root->left, res, size);
|
|
res[*size] = root->val;
|
|
*size = *size + 1;
|
|
processTraversal(root->right, res, size);
|
|
}
|
|
|
|
int *inorderTraversal(struct TreeNode *root, int *returnSize)
|
|
{
|
|
int *res = malloc(256 * sizeof(int));
|
|
*returnSize = 0;
|
|
processTraversal(root, res, returnSize);
|
|
return res;
|
|
}
|