mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-10 06:26:08 +00:00
refactor: Replace 结点 with 节点 (#452)
* Replace 结点 with 节点 Update the footnotes in the figures * Update mindmap * Reduce the size of the mindmap.png
This commit is contained in:
@@ -18,7 +18,7 @@ int *levelOrder(TreeNode *root, int *size) {
|
||||
queue = (TreeNode **) malloc(sizeof(TreeNode) * MAX_NODE_SIZE);
|
||||
// 队列指针
|
||||
front = 0, rear = 0;
|
||||
// 加入根结点
|
||||
// 加入根节点
|
||||
queue[rear++] = root;
|
||||
// 初始化一个列表,用于保存遍历序列
|
||||
/* 辅助数组 */
|
||||
@@ -28,14 +28,14 @@ int *levelOrder(TreeNode *root, int *size) {
|
||||
while (front < rear) {
|
||||
// 队列出队
|
||||
node = queue[front++];
|
||||
// 保存结点值
|
||||
// 保存节点值
|
||||
arr[index++] = node->val;
|
||||
if (node->left != NULL) {
|
||||
// 左子结点入队
|
||||
// 左子节点入队
|
||||
queue[rear++] = node->left;
|
||||
}
|
||||
if (node->right != NULL) {
|
||||
// 右子结点入队
|
||||
// 右子节点入队
|
||||
queue[rear++] = node->right;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ int main() {
|
||||
/* 层序遍历 */
|
||||
// 需要传入数组的长度
|
||||
int *arr = levelOrder(root, &size);
|
||||
printf("层序遍历的结点打印序列 = ");
|
||||
printf("层序遍历的节点打印序列 = ");
|
||||
printArray(arr, size);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user