mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
add JavaScript codes for PrintUtil
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
* Author: IsChristina (christinaxia77@foxmail.com)
|
||||
*/
|
||||
|
||||
let { arrToTree } = require("../include/TreeNode");
|
||||
const { arrToTree } = require("../include/TreeNode");
|
||||
const { printTree } = require("../include/PrintUtil");
|
||||
|
||||
/* 层序遍历 */
|
||||
function hierOrder(root) {
|
||||
@@ -29,7 +30,7 @@ function hierOrder(root) {
|
||||
// 这里借助了一个从数组直接生成二叉树的函数
|
||||
var root = arrToTree([1, 2, 3, 4, 5, 6, 7, null, null, null, null, null, null, null, null ]);
|
||||
console.log("\n初始化二叉树\n");
|
||||
console.log(root);
|
||||
printTree(root);
|
||||
|
||||
/* 层序遍历 */
|
||||
let list = hierOrder(root);
|
||||
|
||||
Reference in New Issue
Block a user