mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-09 14:06:06 +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:
@@ -12,7 +12,7 @@ int *arr;
|
||||
/* 前序遍历 */
|
||||
void preOrder(TreeNode *root, int *size) {
|
||||
if (root == NULL) return;
|
||||
// 访问优先级:根结点 -> 左子树 -> 右子树
|
||||
// 访问优先级:根节点 -> 左子树 -> 右子树
|
||||
arr[(*size)++] = root->val;
|
||||
preOrder(root->left, size);
|
||||
preOrder(root->right, size);
|
||||
@@ -21,7 +21,7 @@ void preOrder(TreeNode *root, int *size) {
|
||||
/* 中序遍历 */
|
||||
void inOrder(TreeNode *root, int *size) {
|
||||
if (root == NULL) return;
|
||||
// 访问优先级:左子树 -> 根结点 -> 右子树
|
||||
// 访问优先级:左子树 -> 根节点 -> 右子树
|
||||
inOrder(root->left, size);
|
||||
arr[(*size)++] = root->val;
|
||||
inOrder(root->right, size);
|
||||
@@ -30,7 +30,7 @@ void inOrder(TreeNode *root, int *size) {
|
||||
/* 后序遍历 */
|
||||
void postOrder(TreeNode *root, int *size) {
|
||||
if (root == NULL) return;
|
||||
// 访问优先级:左子树 -> 右子树 -> 根结点
|
||||
// 访问优先级:左子树 -> 右子树 -> 根节点
|
||||
postOrder(root->left, size);
|
||||
postOrder(root->right, size);
|
||||
arr[(*size)++] = root->val;
|
||||
@@ -52,19 +52,19 @@ int main() {
|
||||
arr = (int *) malloc(sizeof(int) * MAX_NODE_SIZE);
|
||||
size = 0;
|
||||
preOrder(root, &size);
|
||||
printf("前序遍历的结点打印序列 = ");
|
||||
printf("前序遍历的节点打印序列 = ");
|
||||
printArray(arr, size);
|
||||
|
||||
/* 中序遍历 */
|
||||
size = 0;
|
||||
inOrder(root, &size);
|
||||
printf("中序遍历的结点打印序列 = ");
|
||||
printf("中序遍历的节点打印序列 = ");
|
||||
printArray(arr, size);
|
||||
|
||||
/* 后序遍历 */
|
||||
size = 0;
|
||||
postOrder(root, &size);
|
||||
printf("后序遍历的结点打印序列 = ");
|
||||
printf("后序遍历的节点打印序列 = ");
|
||||
printArray(arr, size);
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user