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

View File

@@ -7,7 +7,7 @@
const { arrToTree } = require('../modules/TreeNode');
const { printTree } = require('../modules/PrintUtil');
/* 配列表現による二分木クラス */
/* 配列で表した二分木クラス */
class ArrayBinaryTree {
#tree;
@@ -16,29 +16,29 @@ class ArrayBinaryTree {
this.#tree = arr;
}
/* リスト容量 */
/* リストの容量 */
size() {
return this.#tree.length;
}
/* インデックス i のノードの値を取得 */
/* インデックス i のノードの値を取得する */
val(i) {
// インデックスが範囲外なら、空きを表す null を返す
// インデックスが範囲外の場合、空きを表す null を返す
if (i < 0 || i >= this.size()) return null;
return this.#tree[i];
}
/* インデックス i のノードの左子ノードのインデックスを取得 */
/* インデックス i のノードの左の子ノードのインデックスを取得する */
left(i) {
return 2 * i + 1;
}
/* インデックス i のノードの右子ノードのインデックスを取得 */
/* インデックス i のノードの右の子ノードのインデックスを取得する */
right(i) {
return 2 * i + 2;
}
/* インデックス i のノードの親ノードのインデックスを取得 */
/* インデックス i のノードの親ノードのインデックスを取得する */
parent(i) {
return Math.floor((i - 1) / 2); // 切り捨て除算
}
@@ -46,42 +46,42 @@ class ArrayBinaryTree {
/* レベル順走査 */
levelOrder() {
let res = [];
// 配列を直接走査する
// 配列をそのまま走査する
for (let i = 0; i < this.size(); i++) {
if (this.val(i) !== null) res.push(this.val(i));
}
return res;
}
/* 深さ優先探索 */
/* 深さ優先走査 */
#dfs(i, order, res) {
// 空きスロットなら返す
// 空きの場合、戻る
if (this.val(i) === null) return;
// 先行順走査
// 行きがけ順走査
if (order === 'pre') res.push(this.val(i));
this.#dfs(this.left(i), order, res);
// 中順走査
// 通りがけ順走査
if (order === 'in') res.push(this.val(i));
this.#dfs(this.right(i), order, res);
// 後順走査
// 帰りがけ順走査
if (order === 'post') res.push(this.val(i));
}
/* 先行順走査 */
/* 行きがけ順走査 */
preOrder() {
const res = [];
this.#dfs(0, 'pre', res);
return res;
}
/* 中順走査 */
/* 通りがけ順走査 */
inOrder() {
const res = [];
this.#dfs(0, 'in', res);
return res;
}
/* 後順走査 */
/* 帰りがけ順走査 */
postOrder() {
const res = [];
this.#dfs(0, 'post', res);
@@ -89,9 +89,9 @@ class ArrayBinaryTree {
}
}
/* Driver Code */
// 二分木を初期化
// ここでは、配列から直接二分木を生成する関数を利用する
/* 実行用コード */
// 二分木を初期化する
// ここでは配列から二分木を直接生成する関数を使う
const arr = Array.of(
1,
2,
@@ -111,37 +111,37 @@ const arr = Array.of(
);
const root = arrToTree(arr);
console.log('\n二分木を初期化\n');
console.log('\n二分木を初期化する\n');
console.log('二分木の配列表現:');
console.log(arr);
console.log('二分木の連結リスト表現:');
printTree(root);
// 配列表現による二分木クラス
// 配列で表した二分木クラス
const abt = new ArrayBinaryTree(arr);
// ノードにアクセス
// ノードにアクセスする
const i = 1;
const l = abt.left(i);
const r = abt.right(i);
const p = abt.parent(i);
console.log('\n現在のノードのインデックスは ' + i + ' ,値は ' + abt.val(i));
console.log('\n現在のノードのインデックスは ' + i + ' 、値は ' + abt.val(i));
console.log(
'その左子ノードのインデックスは ' + l + ' ,値は ' + (l === null ? 'null' : abt.val(l))
'左の子ノードのインデックスは ' + l + ' 、値は ' + (l === null ? 'null' : abt.val(l))
);
console.log(
'その右子ノードのインデックスは ' + r + ' ,値は ' + (r === null ? 'null' : abt.val(r))
'右の子ノードのインデックスは ' + r + ' 、値は ' + (r === null ? 'null' : abt.val(r))
);
console.log(
'その親ノードのインデックスは ' + p + ' ,値は ' + (p === null ? 'null' : abt.val(p))
'親ノードのインデックスは ' + p + ' 、値は ' + (p === null ? 'null' : abt.val(p))
);
// 木を走査
// 木を走査する
let res = abt.levelOrder();
console.log('\nレベル順走査:' + res);
res = abt.preOrder();
console.log('先行順走査:' + res);
console.log('行きがけ順走査:' + res);
res = abt.inOrder();
console.log('中間順走査:' + res);
console.log('通りがけ順走査:' + res);
res = abt.postOrder();
console.log('後行順走査:' + res);
console.log('帰りがけ順走査:' + res);