mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-27 15:02:16 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -9,7 +9,7 @@ namespace hello_algo.chapter_tree;
|
||||
public class binary_tree_dfs {
|
||||
List<int> list = [];
|
||||
|
||||
/* 先行順走査 */
|
||||
/* 行きがけ順走査 */
|
||||
void PreOrder(TreeNode? root) {
|
||||
if (root == null) return;
|
||||
// 訪問順序:根ノード -> 左部分木 -> 右部分木
|
||||
@@ -18,19 +18,19 @@ public class binary_tree_dfs {
|
||||
PreOrder(root.right);
|
||||
}
|
||||
|
||||
/* 中順走査 */
|
||||
/* 通りがけ順走査 */
|
||||
void InOrder(TreeNode? root) {
|
||||
if (root == null) return;
|
||||
// 訪問優先順: 左部分木 -> 根ノード -> 右部分木
|
||||
// 訪問順序:左部分木 -> 根ノード -> 右部分木
|
||||
InOrder(root.left);
|
||||
list.Add(root.val!.Value);
|
||||
InOrder(root.right);
|
||||
}
|
||||
|
||||
/* 後順走査 */
|
||||
/* 帰りがけ順走査 */
|
||||
void PostOrder(TreeNode? root) {
|
||||
if (root == null) return;
|
||||
// 訪問優先順: 左部分木 -> 右部分木 -> 根ノード
|
||||
// 訪問順序:左部分木 -> 右部分木 -> 根ノード
|
||||
PostOrder(root.left);
|
||||
PostOrder(root.right);
|
||||
list.Add(root.val!.Value);
|
||||
@@ -38,22 +38,22 @@ public class binary_tree_dfs {
|
||||
|
||||
[Test]
|
||||
public void Test() {
|
||||
/* 二分木を初期化 */
|
||||
// ここでは、配列から直接二分木を生成する関数を利用する
|
||||
/* 二分木を初期化する */
|
||||
// ここでは配列から二分木を直接生成する関数を使う
|
||||
TreeNode? root = TreeNode.ListToTree([1, 2, 3, 4, 5, 6, 7]);
|
||||
Console.WriteLine("\n二分木を初期化\n");
|
||||
Console.WriteLine("\n二分木を初期化する\n");
|
||||
PrintUtil.PrintTree(root);
|
||||
|
||||
list.Clear();
|
||||
PreOrder(root);
|
||||
Console.WriteLine("\n前順走査のノード出力シーケンス = " + string.Join(",", list));
|
||||
Console.WriteLine("\n行きがけ順走査で表示するノードの順序 = " + string.Join(",", list));
|
||||
|
||||
list.Clear();
|
||||
InOrder(root);
|
||||
Console.WriteLine("\n中順走査のノード出力シーケンス = " + string.Join(",", list));
|
||||
Console.WriteLine("\n通りがけ順走査で表示するノードの順序 = " + string.Join(",", list));
|
||||
|
||||
list.Clear();
|
||||
PostOrder(root);
|
||||
Console.WriteLine("\n後順走査のノード出力シーケンス = " + string.Join(",", list));
|
||||
Console.WriteLine("\n帰りがけ順走査で表示するノードの順序 = " + string.Join(",", list));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user