function treeNode(value){
this.left = null
this.right = null
this.val = value
return this
}
function midSort(tree,arr){
// 中序遍历
if(tree.left) midSort(tree.left,arr)
arr.push(tree.val)
if(tree.right) midSort(tree.right,arr)
return arr
}
function preSort(tree,arr){
// 先序遍历
arr.push(tree.val)
if(tree.left) preSort(tree.left,arr)
if(tree.right) preSort(tree.right,arr)
return arr
}
function postSort(tree,arr){
// 后序遍历
if(tree.left) postSort(tree.left,arr)
if(tree.right) postSort(tree.right,arr)
arr.push(tree.val)
return arr
}