后序遍历(后跟次序遍历)
先打印左边的,再打印右边的,再打印当前的
class Node{
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
}
let a = new Node("a");
let b = new Node("b")
let c = new Node("c")
let d = new Node("d")
let e = new Node("e")
let f = new Node("f")
let g = new Node("g")
a.left = c
a.right = b
c.left = f
c.right = g
b.left = d
b.right = e
function fl(root){
if(root == undefined) return;
fl(root.left)
fl(root.right)
console.log(root.value)
}
fl(a)