Update JavaScript and TypeScript codes for all chapters, rename JavaScript and TypeScript import folder to modules (#402)

* Update JavaScript and TypeScript codes

* Rename JavaScript and TypeScript import folder to modules
This commit is contained in:
Justin Tse
2023-03-03 01:34:53 +08:00
committed by GitHub
parent 7b41e6c2f0
commit e4a98bc9c5
61 changed files with 324 additions and 290 deletions

View File

@@ -1,14 +1,14 @@
/**
* File: binary_tree.js
* File: binary_tree_dfs.js
* Created Time: 2022-12-04
* Author: IsChristina (christinaxia77@foxmail.com)
*/
const { arrToTree } = require("../include/TreeNode");
const { printTree } = require("../include/PrintUtil");
const { arrToTree } = require("../modules/TreeNode");
const { printTree } = require("../modules/PrintUtil");
// 初始化列表,用于存储遍历序列
var list = [];
const list = [];
/* 前序遍历 */
function preOrder(root) {
@@ -40,7 +40,7 @@ function postOrder(root) {
/* Driver Code */
/* 初始化二叉树 */
// 这里借助了一个从数组直接生成二叉树的函数
var root = arrToTree([1, 2, 3, 4, 5, 6, 7]);
const root = arrToTree([1, 2, 3, 4, 5, 6, 7]);
console.log("\n初始化二叉树\n");
printTree(root);