mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-08 13:24:07 +08:00
Fomrat the JS and TS codes with prettier.
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
* Author: IsChristina (christinaxia77@foxmail.com)
|
||||
*/
|
||||
|
||||
const { arrToTree } = require("../modules/TreeNode");
|
||||
const { printTree } = require("../modules/PrintUtil");
|
||||
const { arrToTree } = require('../modules/TreeNode');
|
||||
const { printTree } = require('../modules/PrintUtil');
|
||||
|
||||
// 初始化列表,用于存储遍历序列
|
||||
const list = [];
|
||||
@@ -41,20 +41,20 @@ function postOrder(root) {
|
||||
/* 初始化二叉树 */
|
||||
// 这里借助了一个从数组直接生成二叉树的函数
|
||||
const root = arrToTree([1, 2, 3, 4, 5, 6, 7]);
|
||||
console.log("\n初始化二叉树\n");
|
||||
console.log('\n初始化二叉树\n');
|
||||
printTree(root);
|
||||
|
||||
/* 前序遍历 */
|
||||
list.length = 0;
|
||||
preOrder(root);
|
||||
console.log("\n前序遍历的节点打印序列 = " + list);
|
||||
console.log('\n前序遍历的节点打印序列 = ' + list);
|
||||
|
||||
/* 中序遍历 */
|
||||
list.length = 0;
|
||||
inOrder(root);
|
||||
console.log("\n中序遍历的节点打印序列 = " + list);
|
||||
console.log('\n中序遍历的节点打印序列 = ' + list);
|
||||
|
||||
/* 后序遍历 */
|
||||
list.length = 0;
|
||||
postOrder(root);
|
||||
console.log("\n后序遍历的节点打印序列 = " + list);
|
||||
console.log('\n后序遍历的节点打印序列 = ' + list);
|
||||
|
||||
Reference in New Issue
Block a user