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

@@ -0,0 +1,34 @@
/**
* File: binary_tree_bfs.js
* Created Time: 2022-12-04
* Author: IsChristina (christinaxia77@foxmail.com)
*/
const { arrToTree } = require('../modules/TreeNode');
const { printTree } = require('../modules/PrintUtil');
/* レベル順走査 */
function levelOrder(root) {
// キューを初期化し、ルートノードを追加する
const queue = [root];
// 走査順序を保存するためのリストを初期化する
const list = [];
while (queue.length) {
let node = queue.shift(); // デキュー
list.push(node.val); // ノードの値を保存する
if (node.left) queue.push(node.left); // 左子ノードをキューに追加
if (node.right) queue.push(node.right); // 右子ノードをキューに追加
}
return list;
}
/* Driver Code */
/* 二分木を初期化 */
// ここでは、配列から直接二分木を生成する関数を利用する
const root = arrToTree([1, 2, 3, 4, 5, 6, 7]);
console.log('\n二分木を初期化\n');
printTree(root);
/* レベル順走査 */
const list = levelOrder(root);
console.log('\nレベル順走査のード出力シーケンス = ' + list);