mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-24 02:21:30 +08: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:
@@ -13,7 +13,7 @@ List<int> list = [];
|
||||
/* 前序遍历 */
|
||||
void preOrder(TreeNode? node) {
|
||||
if (node == null) return;
|
||||
// 访问优先级:根结点 -> 左子树 -> 右子树
|
||||
// 访问优先级:根节点 -> 左子树 -> 右子树
|
||||
list.add(node.val);
|
||||
preOrder(node.left);
|
||||
preOrder(node.right);
|
||||
@@ -22,7 +22,7 @@ void preOrder(TreeNode? node) {
|
||||
/* 中序遍历 */
|
||||
void inOrder(TreeNode? node) {
|
||||
if (node == null) return;
|
||||
// 访问优先级:左子树 -> 根结点 -> 右子树
|
||||
// 访问优先级:左子树 -> 根节点 -> 右子树
|
||||
inOrder(node.left);
|
||||
list.add(node.val);
|
||||
inOrder(node.right);
|
||||
@@ -31,7 +31,7 @@ void inOrder(TreeNode? node) {
|
||||
/* 后序遍历 */
|
||||
void postOrder(TreeNode? node) {
|
||||
if (node == null) return;
|
||||
// 访问优先级:左子树 -> 右子树 -> 根结点
|
||||
// 访问优先级:左子树 -> 右子树 -> 根节点
|
||||
postOrder(node.left);
|
||||
postOrder(node.right);
|
||||
list.add(node.val);
|
||||
@@ -48,15 +48,15 @@ void main() {
|
||||
/* 前序遍历 */
|
||||
list.clear();
|
||||
preOrder(root);
|
||||
print("\n前序遍历的结点打印序列 = $list");
|
||||
print("\n前序遍历的节点打印序列 = $list");
|
||||
|
||||
/* 中序遍历 */
|
||||
list.clear();
|
||||
inOrder(root);
|
||||
print("\n中序遍历的结点打印序列 = $list");
|
||||
print("\n中序遍历的节点打印序列 = $list");
|
||||
|
||||
/* 后序遍历 */
|
||||
list.clear();
|
||||
postOrder(root);
|
||||
print("\n后序遍历的结点打印序列 = $list");
|
||||
print("\n后序遍历的节点打印序列 = $list");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user