This commit is contained in:
krahets
2023-10-27 20:41:59 +08:00
parent 25ac5de466
commit a42c1d62b9
5 changed files with 34 additions and 33 deletions

View File

@ -258,14 +258,14 @@ comments: true
TreeNode **queue;
/* 辅助队列 */
queue = (TreeNode **)malloc(sizeof(TreeNode *) * MAX_NODE_SIZE);
queue = (TreeNode **)malloc(sizeof(TreeNode *) * MAX_SIZE);
// 队列指针
front = 0, rear = 0;
// 加入根节点
queue[rear++] = root;
// 初始化一个列表,用于保存遍历序列
/* 辅助数组 */
arr = (int *)malloc(sizeof(int) * MAX_NODE_SIZE);
arr = (int *)malloc(sizeof(int) * MAX_SIZE);
// 数组指针
index = 0;
while (front < rear) {