add: 从前序与中序遍历序列构造二叉树

This commit is contained in:
2020-05-22 07:30:33 +08:00
parent 2120bcdecf
commit bf6f71f55f
4 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,5 @@
import { buildTree } from '../../src/tree/construct-binary-tree-from-preorder-and-inorder-traversal'
test('从前序与中序遍历序列构造二叉树', () => {
expect(buildTree([3, 9, 20, 15, 7], [9, 3, 15, 20, 7])).toEqual({ left: { left: null, right: null, val: 9 }, right: { left: { left: null, right: null, val: 15 }, right: { left: null, right: null, val: 7 }, val: 20 }, val: 3 })
})