mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-19 07:17:54 +08:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user