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:
Yudong Jin
2026-10-30 02:12:26 +08:00
committed by GitHub
parent 455e8c1281
commit 7257641e0e
1987 changed files with 23531 additions and 23261 deletions
@@ -9,7 +9,7 @@ package chapter_tree;
import utils.*;
import java.util.*;
/* 配列表現による二分木クラス */
/* 配列で表した二分木クラス */
class ArrayBinaryTree {
private List<Integer> tree;
@@ -18,30 +18,30 @@ class ArrayBinaryTree {
tree = new ArrayList<>(arr);
}
/* リスト容量 */
/* リストの容量 */
public int size() {
return tree.size();
}
/* インデックス i のノードの値を取得 */
/* インデックス i のノードの値を取得する */
public Integer val(int i) {
// インデックスが範囲外なら、空きを表す null を返す
// インデックスが範囲外の場合、空きを表す null を返す
if (i < 0 || i >= size())
return null;
return tree.get(i);
}
/* インデックス i のノードの左子ノードのインデックスを取得 */
/* インデックス i のノードの左の子ノードのインデックスを取得する */
public Integer left(int i) {
return 2 * i + 1;
}
/* インデックス i のノードの右子ノードのインデックスを取得 */
/* インデックス i のノードの右の子ノードのインデックスを取得する */
public Integer right(int i) {
return 2 * i + 2;
}
/* インデックス i のノードの親ノードのインデックスを取得 */
/* インデックス i のノードの親ノードのインデックスを取得する */
public Integer parent(int i) {
return (i - 1) / 2;
}
@@ -49,7 +49,7 @@ class ArrayBinaryTree {
/* レベル順走査 */
public List<Integer> levelOrder() {
List<Integer> res = new ArrayList<>();
// 配列を直接走査する
// 配列をそのまま走査する
for (int i = 0; i < size(); i++) {
if (val(i) != null)
res.add(val(i));
@@ -57,39 +57,39 @@ class ArrayBinaryTree {
return res;
}
/* 深さ優先探索 */
/* 深さ優先走査 */
private void dfs(Integer i, String order, List<Integer> res) {
// 空きスロットなら返す
// 空きの場合、戻る
if (val(i) == null)
return;
// 先行順走査
// 行きがけ順走査
if ("pre".equals(order))
res.add(val(i));
dfs(left(i), order, res);
// 中順走査
// 通りがけ順走査
if ("in".equals(order))
res.add(val(i));
dfs(right(i), order, res);
// 後順走査
// 帰りがけ順走査
if ("post".equals(order))
res.add(val(i));
}
/* 先行順走査 */
/* 行きがけ順走査 */
public List<Integer> preOrder() {
List<Integer> res = new ArrayList<>();
dfs(0, "pre", res);
return res;
}
/* 中順走査 */
/* 通りがけ順走査 */
public List<Integer> inOrder() {
List<Integer> res = new ArrayList<>();
dfs(0, "in", res);
return res;
}
/* 後順走査 */
/* 帰りがけ順走査 */
public List<Integer> postOrder() {
List<Integer> res = new ArrayList<>();
dfs(0, "post", res);
@@ -99,38 +99,38 @@ class ArrayBinaryTree {
public class array_binary_tree {
public static void main(String[] args) {
// 二分木を初期化
// ここでは、配列から直接二分木を生成する関数を利用する
// 二分木を初期化する
// ここでは配列から二分木を直接生成する関数を使う
List<Integer> arr = Arrays.asList(1, 2, 3, 4, null, 6, 7, 8, 9, null, null, 12, null, null, 15);
TreeNode root = TreeNode.listToTree(arr);
System.out.println("\n二分木を初期化\n");
System.out.println("二分木の配列表現:");
System.out.println("\n二分木を初期化する\n");
System.out.println("二分木の配列表現:");
System.out.println(arr);
System.out.println("二分木の連結リスト表現:");
System.out.println("二分木の連結リスト表現:");
PrintUtil.printTree(root);
// 配列表現による二分木クラス
// 配列で表した二分木クラス
ArrayBinaryTree abt = new ArrayBinaryTree(arr);
// ノードにアクセス
// ノードにアクセスする
int i = 1;
Integer l = abt.left(i);
Integer r = abt.right(i);
Integer p = abt.parent(i);
System.out.println("\n現在のノードのインデックスは " + i + "、値は " + abt.val(i));
System.out.println("その左子ノードのインデックスは " + l + "、値は " + (l == null ? "null" : abt.val(l)));
System.out.println("その右子ノードのインデックスは " + r + "、値は " + (r == null ? "null" : abt.val(r)));
System.out.println("その親ノードのインデックスは " + p + "、値は " + (p == null ? "null" : abt.val(p)));
System.out.println("\n現在のノードのインデックスは " + i + " 、値は " + abt.val(i));
System.out.println("左の子ノードのインデックスは " + l + " 、値は " + (l == null ? "null" : abt.val(l)));
System.out.println("右の子ノードのインデックスは " + r + " 、値は " + (r == null ? "null" : abt.val(r)));
System.out.println("親ノードのインデックスは " + p + " 、値は " + (p == null ? "null" : abt.val(p)));
// 木を走査
// 木を走査する
List<Integer> res = abt.levelOrder();
System.out.println("\nレベル順走査: " + res);
System.out.println("\nレベル順走査:" + res);
res = abt.preOrder();
System.out.println("前順走査: " + res);
System.out.println("行きがけ順走査:" + res);
res = abt.inOrder();
System.out.println("中順走査: " + res);
System.out.println("通りがけ順走査:" + res);
res = abt.postOrder();
System.out.println("後順走査: " + res);
System.out.println("帰りがけ順走査:" + res);
}
}