Update 二叉树的递归遍历.md

修改了c语言实现的先序遍历函数名 和内部调用时用的函数名
及在preorderTraversal中的调用先序遍历操作的函数名
This commit is contained in:
Guacker
2022-04-17 17:19:00 +08:00
committed by GitHub
parent ed0052e6c9
commit 0375a5b147

View File

@ -371,18 +371,18 @@ C:
```c
//前序遍历:
void preOrderTraversal(struct TreeNode* root, int* ret, int* returnSize) {
void preOrder(struct TreeNode* root, int* ret, int* returnSize) {
if(root == NULL)
return;
ret[(*returnSize)++] = root->val;
preOrderTraverse(root->left, ret, returnSize);
preOrderTraverse(root->right, ret, returnSize);
preOrder(root->left, ret, returnSize);
preOrder(root->right, ret, returnSize);
}
int* preorderTraversal(struct TreeNode* root, int* returnSize){
int* ret = (int*)malloc(sizeof(int) * 100);
*returnSize = 0;
preOrderTraversal(root, ret, returnSize);
preOrder(root, ret, returnSize);
return ret;
}