Re-translate the Japanese version (#1871)

* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
This commit is contained in:
Yudong Jin
2026-03-30 07:30:15 +08:00
committed by GitHub
parent fe6443235b
commit d7b2277d2b
1444 changed files with 83312 additions and 8363 deletions

View File

@@ -12,10 +12,10 @@ from modules import TreeNode, list_to_tree, print_tree
def pre_order(root: TreeNode | None):
"""順走査"""
"""先行順走査"""
if root is None:
return
# 訪問順序: ルートノード -> 左部分木 -> 右部分木
# 訪問順序:根ノード -> 左部分木 -> 右部分木
res.append(root.val)
pre_order(root=root.left)
pre_order(root=root.right)
@@ -25,7 +25,7 @@ def in_order(root: TreeNode | None):
"""中順走査"""
if root is None:
return
# 訪問順: 左部分木 -> ルートノード -> 右部分木
# 訪問優先順: 左部分木 -> ノード -> 右部分木
in_order(root=root.left)
res.append(root.val)
in_order(root=root.right)
@@ -35,31 +35,31 @@ def post_order(root: TreeNode | None):
"""後順走査"""
if root is None:
return
# 訪問順: 左部分木 -> 右部分木 -> ルートノード
# 訪問優先順: 左部分木 -> 右部分木 -> ノード
post_order(root=root.left)
post_order(root=root.right)
res.append(root.val)
"""ドライバコード"""
"""Driver Code"""
if __name__ == "__main__":
# 二分木を初期化
# 特定の関数を使用して配列を二分木に変換
# ここでは、配列から直接二分木を生成する関数を利用する
root = list_to_tree(arr=[1, 2, 3, 4, 5, 6, 7])
print("\n二分木を初期化\n")
print_tree(root)
# 順走査
# 先行順走査
res = []
pre_order(root)
print("\n順走査のノードシーケンスを出力 = ", res)
print("\n先行順走査のノード出力シーケンス = ", res)
# 中順走査
res.clear()
in_order(root)
print("\n中順走査のノードシーケンスを出力 = ", res)
print("\n順走査のノード出力シーケンス = ", res)
# 後順走査
res.clear()
post_order(root)
print("\n後順走査のノードシーケンスを出力 = ", res)
print("\n順走査のノード出力シーケンス = ", res)